Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-01-30 06:44:06
Exec Total Coverage
Lines: 1717 3947 43.5%
Functions: 126 338 37.3%
Branches: 926 2714 34.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101 bool is_sys_pal = false;
102 static bool load_control_called_this_frame;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 // Dialogue largening
171 void large_dialog(DIALOG *d)
172 {
173 large_dialog(d, 1.5);
174 }
175
176 void large_dialog(DIALOG *d, float RESIZE_AMT)
177 {
178 if(!d[0].d1)
179 {
180 d[0].d1 = 1;
181 int32_t oldwidth = d[0].w;
182 int32_t oldheight = d[0].h;
183 int32_t oldx = d[0].x;
184 int32_t oldy = d[0].y;
185 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
186 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
187 d[0].w = int32_t(d[0].w*RESIZE_AMT);
188 d[0].h = int32_t(d[0].h*RESIZE_AMT);
189
190 for(int32_t i=1; d[i].proc !=NULL; i++)
191 {
192 // Place elements horizontally
193 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
194 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
195
196 if(d[i].proc != d_stringloader)
197 {
198 if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].w *= 2;
201 }
202 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
203 }
204
205 // Place elements vertically
206 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
207 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
208
209 // Vertically resize elements
210 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
211 {
212 d[i].h = int32_t((double)d[i].h*1.5);
213 }
214 else if(d[i].proc == jwin_droplist_proc)
215 {
216 d[i].y += int32_t((double)d[i].h*0.25);
217 d[i].h = int32_t((double)d[i].h*1.25);
218 }
219 else if(d[i].proc==d_bitmap_proc)
220 {
221 d[i].h *= 2;
222 }
223 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
224
225 // Fix frames
226 if(d[i].proc == jwin_frame_proc)
227 {
228 d[i].x++;
229 d[i].y++;
230 d[i].w-=4;
231 d[i].h-=4;
232 }
233 }
234 }
235
236 for(int32_t i=1; d[i].proc!=NULL; i++)
237 {
238 if(d[i].proc==jwin_slider_proc)
239 continue;
240
241 // Bigger font
242 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
243
244 if(!d[i].dp2 && bigfontproc)
245 {
246 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
247 d[i].dp2 = lfont_l;
248 }
249 else if(!bigfontproc)
250 {
251 // ((ListData *)d[i].dp)->font = &sfont3;
252 ((ListData *)d[i].dp)->font = &lfont_l;
253 }
254
255 // Make checkboxes work
256 if(d[i].proc == jwin_check_proc)
257 d[i].proc = jwin_checkfont_proc;
258 else if(d[i].proc == jwin_radio_proc)
259 d[i].proc = jwin_radiofont_proc;
260 }
261
262 jwin_center_dialog(d);
263 }
264
265
266 /**********************************/
267 /******** System functions ********/
268 /**********************************/
269
270 static char cfg_sect[] = "zeldadx"; //We need to rename this.
271 static char ctrl_sect[] = "Controls";
272 static char sfx_sect[] = "Volume";
273
274 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
275 {
276 return D_O_K;
277 }
278
279 26 void load_game_configs()
280 {
281 26 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
282 26 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
283 26 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
284 26 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
285 26 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
286 26 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
287 26 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
288 26 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
289 26 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
290 26 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
291 26 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
292 26 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
293 26 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
294 26 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
295 26 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
296
297 //cheat modifier keya
298 26 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
299 26 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
300 26 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
301 26 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
302
303
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
304 joystick_index = 0;
305
306 26 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
307 26 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
308 26 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
309 26 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
310 26 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
311 26 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
312 26 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
313 26 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
314 26 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
315 26 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
316
317 26 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
318 26 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
319 26 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
320 26 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
321
322 26 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
323 26 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
324 26 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
325 26 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
326 26 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
327 26 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
328 26 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
329 26 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
330 26 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
331 26 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
332 26 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
333
334 26 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
335 26 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
336 26 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
337 26 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
338
339 26 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
340
341 26 digi_volume = zc_get_config(sfx_sect,"digi",248);
342 26 midi_volume = zc_get_config(sfx_sect,"midi",255);
343 26 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
344 26 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
345 26 pan_style = zc_get_config(sfx_sect,"pan",1);
346 // 1 <= zcmusic_bufsz <= 128
347 26 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
348 26 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
349 26 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
350 26 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
351 26 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
352 26 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
353 26 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
354 #ifdef __EMSCRIPTEN__
355 if (em_is_mobile()) NameEntryMode = 2;
356 #endif
357 26 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
358 26 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
359 26 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
360 26 title_version = zc_get_config(cfg_sect,"title",2);
361 26 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
362 26 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
363
364 //default - scale x2, 640 x 480
365 26 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
366 26 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
367 26 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
368 26 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
369 26 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
370
371 26 loadlast = zc_get_config(cfg_sect,"load_last",0);
372
373 26 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
374
375 26 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
376
377 26 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
378
379 #ifdef _WIN32
380 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
381 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
382 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
383 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
384
385 // This one's for Aero
386 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
387
388 // And this one fixes patches unloading on some MIDI setups
389 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
390 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
391 #else //UNIX
392 26 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
393 26 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
394 26 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
395 #endif
396 26 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
397
398 26 char const* default_path = "";
399 26 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
400
401
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(strlen(qstdir)==0)
402 {
403 26 getcwd(qstdir,2048);
404 26 fix_filename_case(qstdir);
405 26 fix_filename_slashes(qstdir);
406 26 put_backslash(qstdir);
407 26 }
408 else
409 {
410 chop_path(qstdir);
411 }
412
413 26 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
414 26 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
415 26 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
416 26 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
417 26 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
418 26 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
419 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
420 26 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
421 26 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
422 26 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
423 26 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
424 26 }
425
426 void save_control_configs(bool kb)
427 {
428 if(kb)
429 {
430 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
431 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
432 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
433 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
434
435 if (!replay_is_replaying())
436 {
437 zc_set_config(ctrl_sect,"key_a",Akey);
438 zc_set_config(ctrl_sect,"key_b",Bkey);
439 zc_set_config(ctrl_sect,"key_s",Skey);
440 zc_set_config(ctrl_sect,"key_l",Lkey);
441 zc_set_config(ctrl_sect,"key_r",Rkey);
442 zc_set_config(ctrl_sect,"key_p",Pkey);
443 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
444 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
445 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
446 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
447 zc_set_config(ctrl_sect,"key_up", DUkey);
448 zc_set_config(ctrl_sect,"key_down", DDkey);
449 zc_set_config(ctrl_sect,"key_left", DLkey);
450 zc_set_config(ctrl_sect,"key_right",DRkey);
451 }
452 }
453 else
454 {
455 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
456 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
457 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
458 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
459 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
460 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
461 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
462 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
463 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
464 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
465 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
466 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
467 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
468 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
469
470 zc_set_config(ctrl_sect,"btn_a",Abtn);
471 zc_set_config(ctrl_sect,"btn_b",Bbtn);
472 zc_set_config(ctrl_sect,"btn_s",Sbtn);
473 zc_set_config(ctrl_sect,"btn_m",Mbtn);
474 zc_set_config(ctrl_sect,"btn_l",Lbtn);
475 zc_set_config(ctrl_sect,"btn_r",Rbtn);
476 zc_set_config(ctrl_sect,"btn_p",Pbtn);
477 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
478 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
479 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
480 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
481
482 zc_set_config(ctrl_sect,"btn_up",DUbtn);
483 zc_set_config(ctrl_sect,"btn_down",DDbtn);
484 zc_set_config(ctrl_sect,"btn_left",DLbtn);
485 zc_set_config(ctrl_sect,"btn_right",DRbtn);
486 }
487 }
488
489 void save_game_configs()
490 {
491 packfile_password("");
492
493 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
494
495 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
496 {
497 int o_window_x, o_window_y;
498 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
499 zc_set_config(cfg_sect,"window_x",o_window_x);
500 zc_set_config(cfg_sect,"window_y",o_window_y);
501 }
502
503 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
504 {
505 double monitor_scale = zc_get_monitor_scale();
506 window_width = al_get_display_width(all_get_display()) / monitor_scale;
507 window_height = al_get_display_height(all_get_display()) / monitor_scale;
508 zc_set_config(cfg_sect,"window_width",window_width);
509 zc_set_config(cfg_sect,"window_height",window_height);
510 }
511
512 zc_set_config(cfg_sect,"load_last",loadlast);
513 chop_path(qstdir);
514 zc_set_config(cfg_sect,qst_dir_name,qstdir);
515 zc_set_config("SAVEFILE","save_filename",save_file_name);
516 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
517
518 flush_config_file();
519 #ifdef __EMSCRIPTEN__
520 em_sync_fs();
521 #endif
522 }
523
524 //----------------------------------------------------------------
525
526 // Timers
527
528 19117 void fps_callback()
529 {
530 19117 lastfps=framecnt;
531 19117 dword tempsecs = fps_secs;
532 19117 ++tempsecs;
533 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
534 19117 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
535 19117 ++fps_secs;
536 19117 framecnt=0;
537 19117 }
538
539 END_OF_FUNCTION(fps_callback)
540
541 26 int32_t Z_init_timers()
542 {
543 static bool didit = false;
544 const static char *err_str = "Couldn't allocate timer";
545 26 err_str = err_str; //Unused variable warning
546
547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(didit)
548 return 1;
549
550 26 didit = true;
551
552 LOCK_VARIABLE(lastfps);
553 LOCK_VARIABLE(framecnt);
554 LOCK_FUNCTION(fps_callback);
555
556
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
557 return 0;
558
559 26 return 1;
560 26 }
561
562 void Z_remove_timers()
563 {
564 remove_int(fps_callback);
565 }
566
567 //----------------------------------------------------------------
568
569 void go()
570 {
571 scare_mouse();
572 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
573 unscare_mouse();
574 }
575
576 void comeback()
577 {
578 scare_mouse();
579 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
580 unscare_mouse();
581 }
582
583 void dump_pal(BITMAP *dest)
584 {
585 for(int32_t i=0; i<256; i++)
586 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
587 }
588
589 //----------------------------------------------------------------
590
591 //Handles converting the mouse sprite from the .dat file
592 26 void load_mouse()
593 {
594 26 system_pal();
595 26 scare_mouse();
596 26 set_mouse_sprite(NULL);
597
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
598
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
130 for(int32_t j = 0; j < 4; ++j)
599 {
600 104 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
601 104 BITMAP* subbmp = create_bitmap_ex(8,16,16);
602
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(zcmouse[j])
603 destroy_bitmap(zcmouse[j]);
604 104 zcmouse[j] = create_bitmap_ex(8,sz,sz);
605 104 clear_bitmap(zcmouse[j]);
606 104 clear_bitmap(tmpbmp);
607 104 clear_bitmap(subbmp);
608 104 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
609
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 104 times.
1768 for(int32_t x = 0; x < 16; ++x)
610 {
611
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 1664 times.
28288 for(int32_t y = 0; y < 16; ++y)
612 {
613 26624 int32_t color = getpixel(tmpbmp, x, y);
614
5/5
✓ Branch 0 taken 24492 times.
✓ Branch 1 taken 494 times.
✓ Branch 2 taken 572 times.
✓ Branch 3 taken 598 times.
✓ Branch 4 taken 468 times.
26624 switch(color)
615 {
616 case dvc(1):
617 494 color = jwin_pal[jcCURSORMISC];
618 494 break;
619 case dvc(2):
620 572 color = jwin_pal[jcCURSOROUTLINE];
621 572 break;
622 case dvc(3):
623 598 color = jwin_pal[jcCURSORLIGHT];
624 598 break;
625 case dvc(5):
626 468 color = jwin_pal[jcCURSORDARK];
627 468 break;
628 }
629 26624 putpixel(subbmp, x, y, color);
630 26624 }
631 1664 }
632
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(sz!=16)
633 104 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
634 else
635 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
636 104 destroy_bitmap(tmpbmp);
637 104 destroy_bitmap(subbmp);
638 104 }
639 26 set_mouse_sprite(zcmouse[0]);
640
641 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
642 26 set_palette(*hw_palette);
643 26 show_mouse(screen);
644 26 show_mouse(NULL);
645
646 26 unscare_mouse();
647 26 game_pal();
648 26 }
649
650 // sets the video mode and initializes the palette and mouse sprite
651 26 bool game_vid_mode(int32_t mode,int32_t wait)
652 {
653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
654 {
655 return false;
656 }
657
658 26 scrx = (resx-320)>>1;
659 26 scry = (resy-240)>>1;
660
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
130 for(int32_t q = 0; q < 4; ++q)
661 104 zcmouse[q] = NULL;
662 26 load_mouse();
663 26 set_mouse_sprite(zcmouse[0]);
664
665
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 26 times.
442 for(int32_t i=240; i<256; i++)
666 416 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
667
668 26 set_palette(RAMpal);
669 26 clear_to_color(screen,BLACK);
670
671 26 rest(wait);
672 26 return true;
673 26 }
674
675 4 void null_quest()
676 {
677 char qstdat_string[2048];
678 4 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
679 4 strcat(qstdat_string,"#NESQST_NEW_QST");
680
681 #ifdef __EMSCRIPTEN__
682 // The quest template data file is not included because it's really big and isn't really needed
683 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
684 // which is much smaller.
685 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
686 #endif
687
688 4 byte skip_flags[4] = { 0 };
689
690 4 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
691 4 }
692
693 4 void init_NES_mode()
694 {
695 /*
696 // qst.dat may not load correctly without this...
697 QHeader.templatepath[0]='\0';
698
699 if(!init_colordata(true, &QHeader, &QMisc))
700 {
701 return;
702 }
703
704 loadfullpal();
705 init_tiles(false, &QHeader);
706 */
707 4 null_quest();
708 4 }
709
710 //----------------------------------------------------------------
711
712 qword trianglelines[16]=
713 {
714 0x0000000000000000ULL,
715 0xFD00000000000000ULL,
716 0xFDFD000000000000ULL,
717 0xFDFDFD0000000000ULL,
718 0xFDFDFDFD00000000ULL,
719 0xFDFDFDFDFD000000ULL,
720 0xFDFDFDFDFDFD0000ULL,
721 0xFDFDFDFDFDFDFD00ULL,
722 0xFDFDFDFDFDFDFDFDULL,
723 0x00FDFDFDFDFDFDFDULL,
724 0x0000FDFDFDFDFDFDULL,
725 0x000000FDFDFDFDFDULL,
726 0x00000000FDFDFDFDULL,
727 0x0000000000FDFDFDULL,
728 0x000000000000FDFDULL,
729 0x00000000000000FDULL,
730 };
731
732 word screen_triangles[28][32];
733 /*
734 qword triangles[4][16]= //[direction][value]
735 {
736 {
737 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
738 },
739 {
740 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
741 },
742 {
743 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
744 },
745 {
746 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
747 }
748 };
749 */
750
751
752 /*
753 byte triangles[4][16][8]= //[direction][value][line]
754 {
755 {
756 {
757 0, 0, 0, 0, 0, 0, 0, 0
758 },
759 {
760 1, 0, 0, 0, 0, 0, 0, 0
761 },
762 {
763 2, 1, 0, 0, 0, 0, 0, 0
764 },
765 {
766 3, 2, 1, 0, 0, 0, 0, 0
767 },
768 {
769 4, 3, 2, 1, 0, 0, 0, 0
770 },
771 {
772 5, 4, 3, 2, 1, 0, 0, 0
773 },
774 {
775 6, 5, 4, 3, 2, 1, 0, 0
776 },
777 {
778 7, 6, 5, 4, 3, 2, 1, 0
779 },
780 {
781 8, 7, 6, 5, 4, 3, 2, 1
782 },
783 {
784 8, 8, 7, 6, 5, 4, 3, 2
785 },
786 {
787 8, 8, 8, 7, 6, 5, 4, 3
788 },
789 {
790 8, 8, 8, 8, 7, 6, 5, 4
791 },
792 {
793 8, 8, 8, 8, 8, 7, 6, 5
794 },
795 {
796 8, 8, 8, 8, 8, 8, 7, 6
797 },
798 {
799 8, 8, 8, 8, 8, 8, 8, 7
800 },
801 {
802 8, 8, 8, 8, 8, 8, 8, 8
803 }
804 },
805 {
806 {
807 0, 0, 0, 0, 0, 0, 0, 0
808 },
809 {
810 15, 0, 0, 0, 0, 0, 0, 0
811 },
812 {
813 14, 15, 0, 0, 0, 0, 0, 0
814 },
815 {
816 13, 14, 15, 0, 0, 0, 0, 0
817 },
818 {
819 12, 13, 14, 15, 0, 0, 0, 0
820 },
821 {
822 11, 12, 13, 14, 15, 0, 0, 0
823 },
824 {
825 10, 11, 12, 13, 14, 15, 0, 0
826 },
827 {
828 9, 10, 11, 12, 13, 14, 15, 0
829 },
830 {
831 8, 9, 10, 11, 12, 13, 14, 15
832 },
833 {
834 8, 8, 9, 10, 11, 12, 13, 14
835 },
836 {
837 8, 8, 8, 9, 10, 11, 12, 13
838 },
839 {
840 8, 8, 8, 8, 9, 10, 11, 12
841 },
842 {
843 8, 8, 8, 8, 8, 9, 10, 11
844 },
845 {
846 8, 8, 8, 8, 8, 8, 9, 10
847 },
848 {
849 8, 8, 8, 8, 8, 8, 8, 9
850 },
851 {
852 8, 8, 8, 8, 8, 8, 8, 8
853 }
854 },
855 {
856 {
857 0, 0, 0, 0, 0, 0, 0, 0
858 },
859 {
860 0, 0, 0, 0, 0, 0, 0, 1
861 },
862 {
863 0, 0, 0, 0, 0, 0, 1, 2
864 },
865 {
866 0, 0, 0, 0, 0, 1, 2, 3
867 },
868 {
869 0, 0, 0, 0, 1, 2, 3, 4
870 },
871 {
872 0, 0, 0, 1, 2, 3, 4, 5
873 },
874 {
875 0, 0, 1, 2, 3, 4, 5, 6
876 },
877 {
878 0, 1, 2, 3, 4, 5, 6, 7
879 },
880 {
881 1, 2, 3, 4, 5, 6, 7, 8
882 },
883 {
884 2, 3, 4, 5, 6, 7, 8, 8
885 },
886 {
887 3, 4, 5, 6, 7, 8, 8, 8
888 },
889 {
890 4, 5, 6, 7, 8, 8, 8, 8
891 },
892 {
893 5, 6, 7, 8, 8, 8, 8, 8
894 },
895 {
896 6, 7, 8, 8, 8, 8, 8, 8
897 },
898 {
899 7, 8, 8, 8, 8, 8, 8, 8
900 },
901 {
902 8, 8, 8, 8, 8, 8, 8, 8
903 }
904 },
905 {
906 {
907 0, 0, 0, 0, 0, 0, 0, 0
908 },
909 {
910 0, 0, 0, 0, 0, 0, 0, 15
911 },
912 {
913 0, 0, 0, 0, 0, 0, 15, 14
914 },
915 {
916 0, 0, 0, 0, 0, 15, 14, 13
917 },
918 {
919 0, 0, 0, 0, 15, 14, 13, 12
920 },
921 {
922 0, 0, 0, 15, 14, 13, 12, 11
923 },
924 {
925 0, 0, 15, 14, 13, 12, 11, 10
926 },
927 {
928 0, 15, 14, 13, 12, 11, 10, 9
929 },
930 {
931 15, 14, 13, 12, 11, 10, 9, 8
932 },
933 {
934 14, 13, 12, 11, 10, 9, 8, 8
935 },
936 {
937 13, 12, 11, 10, 9, 8, 8, 8
938 },
939 {
940 12, 11, 10, 9, 8, 8, 8, 8
941 },
942 {
943 11, 10, 9, 8, 8, 8, 8, 8
944 },
945 {
946 10, 9, 8, 8, 8, 8, 8, 8
947 },
948 {
949 9, 8, 8, 8, 8, 8, 8, 8
950 },
951 {
952 8, 8, 8, 8, 8, 8, 8, 8
953 }
954 }
955 };
956 */
957
958
959
960 /*
961 for (int32_t blockrow=0; blockrow<30; ++i)
962 {
963 for (int32_t linerow=0; linerow<8; ++i)
964 {
965 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
966 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
967 {
968 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
969 ++triangleline;
970 }
971 }
972 }
973 */
974
975 // the ULL suffixes are to prevent this warning:
976 // warning: integer constant is too large for "int32_t" type
977
978 qword triangles[4][16][8]= //[direction][value][line]
979 {
980 {
981 {
982 0x0000000000000000ULL,
983 0x0000000000000000ULL,
984 0x0000000000000000ULL,
985 0x0000000000000000ULL,
986 0x0000000000000000ULL,
987 0x0000000000000000ULL,
988 0x0000000000000000ULL,
989 0x0000000000000000ULL
990 },
991 {
992 0xFD00000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL,
998 0x0000000000000000ULL,
999 0x0000000000000000ULL
1000 },
1001 {
1002 0xFDFD000000000000ULL,
1003 0xFD00000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL,
1008 0x0000000000000000ULL,
1009 0x0000000000000000ULL
1010 },
1011 {
1012 0xFDFDFD0000000000ULL,
1013 0xFDFD000000000000ULL,
1014 0xFD00000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL,
1018 0x0000000000000000ULL,
1019 0x0000000000000000ULL
1020 },
1021 {
1022 0xFDFDFDFD00000000ULL,
1023 0xFDFDFD0000000000ULL,
1024 0xFDFD000000000000ULL,
1025 0xFD00000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL,
1028 0x0000000000000000ULL,
1029 0x0000000000000000ULL
1030 },
1031 {
1032 0xFDFDFDFDFD000000ULL,
1033 0xFDFDFDFD00000000ULL,
1034 0xFDFDFD0000000000ULL,
1035 0xFDFD000000000000ULL,
1036 0xFD00000000000000ULL,
1037 0x0000000000000000ULL,
1038 0x0000000000000000ULL,
1039 0x0000000000000000ULL
1040 },
1041 {
1042 0xFDFDFDFDFDFD0000ULL,
1043 0xFDFDFDFDFD000000ULL,
1044 0xFDFDFDFD00000000ULL,
1045 0xFDFDFD0000000000ULL,
1046 0xFDFD000000000000ULL,
1047 0xFD00000000000000ULL,
1048 0x0000000000000000ULL,
1049 0x0000000000000000ULL
1050 },
1051 {
1052 0xFDFDFDFDFDFDFD00ULL,
1053 0xFDFDFDFDFDFD0000ULL,
1054 0xFDFDFDFDFD000000ULL,
1055 0xFDFDFDFD00000000ULL,
1056 0xFDFDFD0000000000ULL,
1057 0xFDFD000000000000ULL,
1058 0xFD00000000000000ULL,
1059 0x0000000000000000ULL
1060 },
1061 {
1062 0xFDFDFDFDFDFDFDFDULL,
1063 0xFDFDFDFDFDFDFD00ULL,
1064 0xFDFDFDFDFDFD0000ULL,
1065 0xFDFDFDFDFD000000ULL,
1066 0xFDFDFDFD00000000ULL,
1067 0xFDFDFD0000000000ULL,
1068 0xFDFD000000000000ULL,
1069 0xFD00000000000000ULL
1070 },
1071 {
1072 0xFDFDFDFDFDFDFDFDULL,
1073 0xFDFDFDFDFDFDFDFDULL,
1074 0xFDFDFDFDFDFDFD00ULL,
1075 0xFDFDFDFDFDFD0000ULL,
1076 0xFDFDFDFDFD000000ULL,
1077 0xFDFDFDFD00000000ULL,
1078 0xFDFDFD0000000000ULL,
1079 0xFDFD000000000000ULL
1080 },
1081 {
1082 0xFDFDFDFDFDFDFDFDULL,
1083 0xFDFDFDFDFDFDFDFDULL,
1084 0xFDFDFDFDFDFDFDFDULL,
1085 0xFDFDFDFDFDFDFD00ULL,
1086 0xFDFDFDFDFDFD0000ULL,
1087 0xFDFDFDFDFD000000ULL,
1088 0xFDFDFDFD00000000ULL,
1089 0xFDFDFD0000000000ULL
1090 },
1091 {
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFDFDULL,
1094 0xFDFDFDFDFDFDFDFDULL,
1095 0xFDFDFDFDFDFDFDFDULL,
1096 0xFDFDFDFDFDFDFD00ULL,
1097 0xFDFDFDFDFDFD0000ULL,
1098 0xFDFDFDFDFD000000ULL,
1099 0xFDFDFDFD00000000ULL
1100 },
1101 {
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFDFDULL,
1105 0xFDFDFDFDFDFDFDFDULL,
1106 0xFDFDFDFDFDFDFDFDULL,
1107 0xFDFDFDFDFDFDFD00ULL,
1108 0xFDFDFDFDFDFD0000ULL,
1109 0xFDFDFDFDFD000000ULL
1110 },
1111 {
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFDFDULL,
1116 0xFDFDFDFDFDFDFDFDULL,
1117 0xFDFDFDFDFDFDFDFDULL,
1118 0xFDFDFDFDFDFDFD00ULL,
1119 0xFDFDFDFDFDFD0000ULL
1120 },
1121 {
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFDFDULL,
1127 0xFDFDFDFDFDFDFDFDULL,
1128 0xFDFDFDFDFDFDFDFDULL,
1129 0xFDFDFDFDFDFDFD00ULL
1130 },
1131 {
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFDFDULL,
1138 0xFDFDFDFDFDFDFDFDULL,
1139 0xFDFDFDFDFDFDFDFDULL
1140 }
1141 },
1142 {
1143 {
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL,
1149 0x0000000000000000ULL,
1150 0x0000000000000000ULL,
1151 0x0000000000000000ULL
1152 },
1153 {
1154 0x00000000000000FDULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL,
1160 0x0000000000000000ULL,
1161 0x0000000000000000ULL
1162 },
1163 {
1164 0x000000000000FDFDULL,
1165 0x00000000000000FDULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL,
1170 0x0000000000000000ULL,
1171 0x0000000000000000ULL
1172 },
1173 {
1174 0x0000000000FDFDFDULL,
1175 0x000000000000FDFDULL,
1176 0x00000000000000FDULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL,
1180 0x0000000000000000ULL,
1181 0x0000000000000000ULL
1182 },
1183 {
1184 0x00000000FDFDFDFDULL,
1185 0x0000000000FDFDFDULL,
1186 0x000000000000FDFDULL,
1187 0x00000000000000FDULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL,
1190 0x0000000000000000ULL,
1191 0x0000000000000000ULL
1192 },
1193 {
1194 0x000000FDFDFDFDFDULL,
1195 0x00000000FDFDFDFDULL,
1196 0x0000000000FDFDFDULL,
1197 0x000000000000FDFDULL,
1198 0x00000000000000FDULL,
1199 0x0000000000000000ULL,
1200 0x0000000000000000ULL,
1201 0x0000000000000000ULL
1202 },
1203 {
1204 0x0000FDFDFDFDFDFDULL,
1205 0x000000FDFDFDFDFDULL,
1206 0x00000000FDFDFDFDULL,
1207 0x0000000000FDFDFDULL,
1208 0x000000000000FDFDULL,
1209 0x00000000000000FDULL,
1210 0x0000000000000000ULL,
1211 0x0000000000000000ULL
1212 },
1213 {
1214 0x00FDFDFDFDFDFDFDULL,
1215 0x0000FDFDFDFDFDFDULL,
1216 0x000000FDFDFDFDFDULL,
1217 0x00000000FDFDFDFDULL,
1218 0x0000000000FDFDFDULL,
1219 0x000000000000FDFDULL,
1220 0x00000000000000FDULL,
1221 0x0000000000000000ULL
1222 },
1223 {
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0x00FDFDFDFDFDFDFDULL,
1226 0x0000FDFDFDFDFDFDULL,
1227 0x000000FDFDFDFDFDULL,
1228 0x00000000FDFDFDFDULL,
1229 0x0000000000FDFDFDULL,
1230 0x000000000000FDFDULL,
1231 0x00000000000000FDULL
1232 },
1233 {
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFDFDULL,
1236 0x00FDFDFDFDFDFDFDULL,
1237 0x0000FDFDFDFDFDFDULL,
1238 0x000000FDFDFDFDFDULL,
1239 0x00000000FDFDFDFDULL,
1240 0x0000000000FDFDFDULL,
1241 0x000000000000FDFDULL
1242 },
1243 {
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFDFDULL,
1247 0x00FDFDFDFDFDFDFDULL,
1248 0x0000FDFDFDFDFDFDULL,
1249 0x000000FDFDFDFDFDULL,
1250 0x00000000FDFDFDFDULL,
1251 0x0000000000FDFDFDULL
1252 },
1253 {
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL,
1257 0xFDFDFDFDFDFDFDFDULL,
1258 0x00FDFDFDFDFDFDFDULL,
1259 0x0000FDFDFDFDFDFDULL,
1260 0x000000FDFDFDFDFDULL,
1261 0x00000000FDFDFDFDULL
1262 },
1263 {
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFDFDULL,
1268 0xFDFDFDFDFDFDFDFDULL,
1269 0x00FDFDFDFDFDFDFDULL,
1270 0x0000FDFDFDFDFDFDULL,
1271 0x000000FDFDFDFDFDULL
1272 },
1273 {
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0xFDFDFDFDFDFDFDFDULL,
1278 0xFDFDFDFDFDFDFDFDULL,
1279 0xFDFDFDFDFDFDFDFDULL,
1280 0x00FDFDFDFDFDFDFDULL,
1281 0x0000FDFDFDFDFDFDULL
1282 },
1283 {
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0xFDFDFDFDFDFDFDFDULL,
1289 0xFDFDFDFDFDFDFDFDULL,
1290 0xFDFDFDFDFDFDFDFDULL,
1291 0x00FDFDFDFDFDFDFDULL
1292 },
1293 {
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0xFDFDFDFDFDFDFDFDULL,
1300 0xFDFDFDFDFDFDFDFDULL,
1301 0xFDFDFDFDFDFDFDFDULL
1302 }
1303 },
1304 {
1305 {
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL,
1311 0x0000000000000000ULL,
1312 0x0000000000000000ULL,
1313 0x0000000000000000ULL
1314 },
1315 {
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL,
1322 0x0000000000000000ULL,
1323 0xFD00000000000000ULL
1324 },
1325 {
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0x0000000000000000ULL,
1332 0xFD00000000000000ULL,
1333 0xFDFD000000000000ULL
1334 },
1335 {
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0x0000000000000000ULL,
1341 0xFD00000000000000ULL,
1342 0xFDFD000000000000ULL,
1343 0xFDFDFD0000000000ULL
1344 },
1345 {
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0x0000000000000000ULL,
1350 0xFD00000000000000ULL,
1351 0xFDFD000000000000ULL,
1352 0xFDFDFD0000000000ULL,
1353 0xFDFDFDFD00000000ULL
1354 },
1355 {
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0x0000000000000000ULL,
1359 0xFD00000000000000ULL,
1360 0xFDFD000000000000ULL,
1361 0xFDFDFD0000000000ULL,
1362 0xFDFDFDFD00000000ULL,
1363 0xFDFDFDFDFD000000ULL
1364 },
1365 {
1366 0x0000000000000000ULL,
1367 0x0000000000000000ULL,
1368 0xFD00000000000000ULL,
1369 0xFDFD000000000000ULL,
1370 0xFDFDFD0000000000ULL,
1371 0xFDFDFDFD00000000ULL,
1372 0xFDFDFDFDFD000000ULL,
1373 0xFDFDFDFDFDFD0000ULL
1374 },
1375 {
1376 0x0000000000000000ULL,
1377 0xFD00000000000000ULL,
1378 0xFDFD000000000000ULL,
1379 0xFDFDFD0000000000ULL,
1380 0xFDFDFDFD00000000ULL,
1381 0xFDFDFDFDFD000000ULL,
1382 0xFDFDFDFDFDFD0000ULL,
1383 0xFDFDFDFDFDFDFD00ULL
1384 },
1385 {
1386 0xFD00000000000000ULL,
1387 0xFDFD000000000000ULL,
1388 0xFDFDFD0000000000ULL,
1389 0xFDFDFDFD00000000ULL,
1390 0xFDFDFDFDFD000000ULL,
1391 0xFDFDFDFDFDFD0000ULL,
1392 0xFDFDFDFDFDFDFD00ULL,
1393 0xFDFDFDFDFDFDFDFDULL
1394 },
1395 {
1396 0xFDFD000000000000ULL,
1397 0xFDFDFD0000000000ULL,
1398 0xFDFDFDFD00000000ULL,
1399 0xFDFDFDFDFD000000ULL,
1400 0xFDFDFDFDFDFD0000ULL,
1401 0xFDFDFDFDFDFDFD00ULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL
1404 },
1405 {
1406 0xFDFDFD0000000000ULL,
1407 0xFDFDFDFD00000000ULL,
1408 0xFDFDFDFDFD000000ULL,
1409 0xFDFDFDFDFDFD0000ULL,
1410 0xFDFDFDFDFDFDFD00ULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL
1414 },
1415 {
1416 0xFDFDFDFD00000000ULL,
1417 0xFDFDFDFDFD000000ULL,
1418 0xFDFDFDFDFDFD0000ULL,
1419 0xFDFDFDFDFDFDFD00ULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL,
1422 0xFDFDFDFDFDFDFDFDULL,
1423 0xFDFDFDFDFDFDFDFDULL
1424 },
1425 {
1426 0xFDFDFDFDFD000000ULL,
1427 0xFDFDFDFDFDFD0000ULL,
1428 0xFDFDFDFDFDFDFD00ULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL,
1432 0xFDFDFDFDFDFDFDFDULL,
1433 0xFDFDFDFDFDFDFDFDULL
1434 },
1435 {
1436 0xFDFDFDFDFDFD0000ULL,
1437 0xFDFDFDFDFDFDFD00ULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL,
1442 0xFDFDFDFDFDFDFDFDULL,
1443 0xFDFDFDFDFDFDFDFDULL
1444 },
1445 {
1446 0xFDFDFDFDFDFDFD00ULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL,
1452 0xFDFDFDFDFDFDFDFDULL,
1453 0xFDFDFDFDFDFDFDFDULL
1454 },
1455 {
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL,
1462 0xFDFDFDFDFDFDFDFDULL,
1463 0xFDFDFDFDFDFDFDFDULL
1464 }
1465 },
1466 {
1467 {
1468 0x0000000000000000ULL,
1469 0x0000000000000000ULL,
1470 0x0000000000000000ULL,
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0x0000000000000000ULL
1476 },
1477 {
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL,
1484 0x0000000000000000ULL,
1485 0x00000000000000FDULL
1486 },
1487 {
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x0000000000000000ULL,
1494 0x00000000000000FDULL,
1495 0x000000000000FDFDULL
1496 },
1497 {
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x0000000000000000ULL,
1503 0x00000000000000FDULL,
1504 0x000000000000FDFDULL,
1505 0x0000000000FDFDFDULL
1506 },
1507 {
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x0000000000000000ULL,
1512 0x00000000000000FDULL,
1513 0x000000000000FDFDULL,
1514 0x0000000000FDFDFDULL,
1515 0x00000000FDFDFDFDULL
1516 },
1517 {
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x0000000000000000ULL,
1521 0x00000000000000FDULL,
1522 0x000000000000FDFDULL,
1523 0x0000000000FDFDFDULL,
1524 0x00000000FDFDFDFDULL,
1525 0x000000FDFDFDFDFDULL
1526 },
1527 {
1528 0x0000000000000000ULL,
1529 0x0000000000000000ULL,
1530 0x00000000000000FDULL,
1531 0x000000000000FDFDULL,
1532 0x0000000000FDFDFDULL,
1533 0x00000000FDFDFDFDULL,
1534 0x000000FDFDFDFDFDULL,
1535 0x0000FDFDFDFDFDFDULL
1536 },
1537 {
1538 0x0000000000000000ULL,
1539 0x00000000000000FDULL,
1540 0x000000000000FDFDULL,
1541 0x0000000000FDFDFDULL,
1542 0x00000000FDFDFDFDULL,
1543 0x000000FDFDFDFDFDULL,
1544 0x0000FDFDFDFDFDFDULL,
1545 0x00FDFDFDFDFDFDFDULL
1546 },
1547 {
1548 0x00000000000000FDULL,
1549 0x000000000000FDFDULL,
1550 0x0000000000FDFDFDULL,
1551 0x00000000FDFDFDFDULL,
1552 0x000000FDFDFDFDFDULL,
1553 0x0000FDFDFDFDFDFDULL,
1554 0x00FDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL
1556 },
1557 {
1558 0x000000000000FDFDULL,
1559 0x0000000000FDFDFDULL,
1560 0x00000000FDFDFDFDULL,
1561 0x000000FDFDFDFDFDULL,
1562 0x0000FDFDFDFDFDFDULL,
1563 0x00FDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL
1566 },
1567 {
1568 0x0000000000FDFDFDULL,
1569 0x00000000FDFDFDFDULL,
1570 0x000000FDFDFDFDFDULL,
1571 0x0000FDFDFDFDFDFDULL,
1572 0x00FDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL
1576 },
1577 {
1578 0x00000000FDFDFDFDULL,
1579 0x000000FDFDFDFDFDULL,
1580 0x0000FDFDFDFDFDFDULL,
1581 0x00FDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL,
1584 0xFDFDFDFDFDFDFDFDULL,
1585 0xFDFDFDFDFDFDFDFDULL
1586 },
1587 {
1588 0x000000FDFDFDFDFDULL,
1589 0x0000FDFDFDFDFDFDULL,
1590 0x00FDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL,
1594 0xFDFDFDFDFDFDFDFDULL,
1595 0xFDFDFDFDFDFDFDFDULL
1596 },
1597 {
1598 0x0000FDFDFDFDFDFDULL,
1599 0x00FDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL,
1604 0xFDFDFDFDFDFDFDFDULL,
1605 0xFDFDFDFDFDFDFDFDULL
1606 },
1607 {
1608 0x00FDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL,
1614 0xFDFDFDFDFDFDFDFDULL,
1615 0xFDFDFDFDFDFDFDFDULL
1616 },
1617 {
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL,
1624 0xFDFDFDFDFDFDFDFDULL,
1625 0xFDFDFDFDFDFDFDFDULL
1626 }
1627 }
1628 };
1629
1630 int32_t black_opening_count=0;
1631 int32_t black_opening_x,black_opening_y;
1632 int32_t black_opening_shape;
1633
1634 482 int32_t choose_opening_shape()
1635 {
1636 // First, count how many bits are set
1637 482 int32_t numBits=0;
1638 int32_t bitCounter;
1639
1640
2/2
✓ Branch 0 taken 2410 times.
✓ Branch 1 taken 482 times.
2892 for(int32_t i=0; i<bosMAX; i++)
1641 {
1642
2/2
✓ Branch 0 taken 1712 times.
✓ Branch 1 taken 698 times.
2410 if(COOLSCROLL&(1<<i))
1643 698 numBits++;
1644 2410 }
1645
1646 // Shouldn't happen...
1647
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(numBits==0)
1648 return bosCIRCLE;
1649
1650 // Pick a bit
1651 482 bitCounter=zc_rand()%numBits+1;
1652
1653
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 26 times.
720 for(int32_t i=0; i<bosMAX; i++)
1654 {
1655 // If this bit is set, decrement the bit counter
1656
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 612 times.
694 if(COOLSCROLL&(1<<i))
1657 612 bitCounter--;
1658
1659 // When the counter hits 0, return a value based on
1660 // which bit it stopped on.
1661 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1662
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 238 times.
694 if(bitCounter==0)
1663 456 return i;
1664 238 }
1665
1666 // Shouldn't be necessary, but the compiler might complain, at least
1667 26 return bosCIRCLE;
1668 482 }
1669
1670 140 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1671 {
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1673
1674 140 int32_t w=256, h=224;
1675 140 int32_t blockrows=28, blockcolumns=32;
1676 140 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1677
1678
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 140 times.
4060 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1679 {
1680
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 3920 times.
129360 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1681 {
1682
2/2
✓ Branch 0 taken 67190 times.
✓ Branch 1 taken 58250 times.
125440 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1683 125440 }
1684 3920 }
1685
1686 140 black_opening_count = 66;
1687 140 black_opening_x = x;
1688 140 black_opening_y = y;
1689 140 lensclk = 0;
1690 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1691
1692
1693
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(black_opening_shape == bosFADEBLACK)
1694 {
1695 refreshTints();
1696 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1697 }
1698
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(wait)
1699 {
1700 FFCore.warpScriptCheck();
1701 for(int32_t i=0; i<66; i++)
1702 {
1703 draw_screen(tmpscr);
1704 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1705 advanceframe(true);
1706
1707 if(Quit)
1708 {
1709 break;
1710 }
1711 }
1712 }
1713 140 }
1714
1715 342 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1716 {
1717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1718
1719 342 int32_t w=256, h=224;
1720 342 int32_t blockrows=28, blockcolumns=32;
1721 342 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1722
1723
2/2
✓ Branch 0 taken 9576 times.
✓ Branch 1 taken 342 times.
9918 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1724 {
1725
2/2
✓ Branch 0 taken 306432 times.
✓ Branch 1 taken 9576 times.
316008 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1726 {
1727
2/2
✓ Branch 0 taken 147245 times.
✓ Branch 1 taken 159187 times.
306432 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1728 306432 }
1729 9576 }
1730
1731 342 black_opening_count = -66;
1732 342 black_opening_x = x;
1733 342 black_opening_y = y;
1734 342 lensclk = 0;
1735
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(black_opening_shape == bosFADEBLACK)
1736 {
1737 refreshTints();
1738 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1739 }
1740
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 232 times.
342 if(wait)
1741 {
1742 232 FFCore.warpScriptCheck();
1743
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 15312 times.
15544 for(int32_t i=0; i<66; i++)
1744 {
1745 15312 draw_screen(tmpscr);
1746 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1747 15312 advanceframe(true);
1748
1749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15312 times.
15312 if(Quit)
1750 {
1751 break;
1752 }
1753 15312 }
1754 232 }
1755 342 }
1756
1757 31812 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1758 {
1759 31812 clear_to_color(tmp_scr,BLACK);
1760 31812 int32_t w=256, h=224;
1761
1762
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28644 times.
31812 switch(black_opening_shape)
1763 {
1764 case bosOVAL:
1765 {
1766 858 double new_w=(w/2)+abs(w/2-x);
1767 858 double new_h=(h/2)+abs(h/2-y);
1768 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1769 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1770 858 break;
1771 }
1772
1773 case bosTRIANGLE:
1774 {
1775 660 double new_w=(w/2)+abs(w/2-x);
1776 660 double new_h=(h/2)+abs(h/2-y);
1777 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1778 660 double P2= (PI/2);
1779 660 double P23=(2*PI/3);
1780 660 double P43=(4*PI/3);
1781 660 double Pa= (-4*PI*a/(3*max_a));
1782 660 double angle=P2+Pa;
1783 660 double a0=angle;
1784 660 double a2=angle+P23;
1785 660 double a4=angle+P43;
1786 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1787 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1788 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1789 0);
1790 660 break;
1791 }
1792
1793 case bosSMAS:
1794 {
1795
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1796
1797
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1798 {
1799
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1800 {
1801 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1802
1803
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1804 {
1805 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1806
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1807 11827200 [linerow];
1808 11827200 ++triangleline;
1809
1810
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1811 {
1812 1478400 }
1813 11827200 }
1814 369600 }
1815 46200 }
1816
1817 1650 break;
1818 }
1819
1820 case bosFADEBLACK:
1821 {
1822 if(black_opening_count<0)
1823 {
1824 black_fade(zc_min(-black_opening_count,63));
1825 }
1826 else if(black_opening_count>0)
1827 {
1828 black_fade(63-zc_max(black_opening_count-3,0));
1829 }
1830 else black_fade(0);
1831 return; //no blitting from tmp_scr!
1832 }
1833
1834 28644 case bosCIRCLE:
1835 default:
1836 {
1837 28644 double new_w=(w/2)+abs(w/2-x);
1838 28644 double new_h=(h/2)+abs(h/2-y);
1839 28644 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1840 //circlefill(tmp_scr,x,y,a<<3,0);
1841 28644 circlefill(tmp_scr,x,y,r,0);
1842 28644 break;
1843 }
1844 }
1845
1846 31812 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1847 31812 }
1848
1849
1850 void black_fade(int32_t fadeamnt)
1851 {
1852 for(int32_t i=0; i < 0xEF; i++)
1853 {
1854 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1855 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1856 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1857 }
1858
1859 refreshpal = true;
1860 }
1861
1862 //----------------------------------------------------------------
1863
1864 12342469 bool item_disabled(int32_t item) //is this item disabled?
1865 {
1866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12342469 times.
12342469 return (item>=0 && game->items_off[item] != 0);
1867 }
1868
1869 3836307 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1870 {
1871
2/2
✓ Branch 0 taken 45639 times.
✓ Branch 1 taken 3790668 times.
3836307 if(current_item(item_type, true) >=item)
1872 {
1873 45639 return true;
1874 }
1875
1876 3790668 return false;
1877 3836307 }
1878
1879 16670498 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1880 {
1881
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2894906 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1831366 times.
✓ Branch 6 taken 8998705 times.
✓ Branch 7 taken 2925185 times.
✓ Branch 8 taken 20336 times.
16670498 switch(item_type)
1882 {
1883 case itype_bomb:
1884 case itype_sbomb:
1885 {
1886 int32_t itemid = getItemID(itemsbuf, item_type, it);
1887
1888 if(itemid == -1)
1889 return false;
1890
1891 return (game->get_item(itemid));
1892 }
1893
1894 case itype_clock:
1895 {
1896 2894906 int32_t itemid = getItemID(itemsbuf, item_type, it);
1897
1898
2/4
✓ Branch 0 taken 2894906 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2894906 times.
✗ Branch 3 not taken.
2894906 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1899 return (game->get_item(itemid));
1900 2894906 return Hero.getClock()?1:0;
1901 }
1902
1903 case itype_key:
1904 return (game->get_keys()>0);
1905
1906 case itype_magiccontainer:
1907 return (game->get_maxmagic()>=game->get_mp_per_block());
1908
1909 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1910 {
1911
1/3
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1831366 switch(it)
1912 {
1913 case -2:
1914 {
1915 for(int32_t i=0; i<MAXLEVELS; i++)
1916 {
1917 if(game->lvlitems[i]&liTRIFORCE)
1918 {
1919 return true;
1920 }
1921 }
1922
1923 return false;
1924 }
1925
1926 case -1:
1927 return (game->lvlitems[dlevel]&liTRIFORCE);
1928
1929 default:
1930
2/4
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1831366 times.
1831366 if(it>=0&&it<MAXLEVELS)
1931 {
1932 1831366 return (game->lvlitems[it]&liTRIFORCE);
1933 }
1934
1935 break;
1936 }
1937
1938 return 0;
1939 }
1940
1941 case itype_map: //it: -2=any, -1=current level, other=that level
1942 {
1943
1/3
✓ Branch 0 taken 8998705 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
8998705 switch(it)
1944 {
1945 case -2:
1946 {
1947 for(int32_t i=0; i<MAXLEVELS; i++)
1948 {
1949 if(game->lvlitems[i]&liMAP)
1950 {
1951 return true;
1952 }
1953 }
1954
1955 return false;
1956 }
1957
1958 case -1:
1959 return (game->lvlitems[dlevel]&liMAP)!=0;
1960
1961 default:
1962
2/4
✓ Branch 0 taken 8998705 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8998705 times.
8998705 if(it>=0&&it<MAXLEVELS)
1963 {
1964 8998705 return (game->lvlitems[it]&liMAP)!=0;
1965 }
1966
1967 break;
1968 }
1969
1970 return 0;
1971 }
1972
1973 case itype_compass: //it: -2=any, -1=current level, other=that level
1974 {
1975
1/3
✓ Branch 0 taken 2925185 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2925185 switch(it)
1976 {
1977 case -2:
1978 {
1979 for(int32_t i=0; i<MAXLEVELS; i++)
1980 {
1981 if(game->lvlitems[i]&liCOMPASS)
1982 {
1983 return true;
1984 }
1985 }
1986
1987 return false;
1988 }
1989
1990 case -1:
1991 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
1992
1993 default:
1994
2/4
✓ Branch 0 taken 2925185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2925185 times.
✗ Branch 3 not taken.
2925185 if(it>=0&&it<MAXLEVELS)
1995 {
1996 2925185 return (game->lvlitems[it]&liCOMPASS)!=0;
1997 }
1998
1999 break;
2000 }
2001 return 0;
2002 }
2003
2004 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2005 {
2006
1/3
✓ Branch 0 taken 20336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
20336 switch(it)
2007 {
2008 case -2:
2009 {
2010 for(int32_t i=0; i<MAXLEVELS; i++)
2011 {
2012 if(game->lvlitems[i]&liBOSSKEY)
2013 {
2014 return true;
2015 }
2016 }
2017
2018 return false;
2019 }
2020
2021 case -1:
2022 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2023
2024 default:
2025
2/4
✓ Branch 0 taken 20336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20336 times.
20336 if(it>=0&&it<MAXLEVELS)
2026 {
2027 20336 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2028 }
2029 break;
2030 }
2031 return 0;
2032 }
2033
2034 default:
2035 //it=(1<<(it-1));
2036 /*if (item_type>=itype_max)
2037 {
2038 system_pal();
2039 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2040 game_pal();
2041
2042 return false;
2043 }*/
2044 int32_t itemid = getItemID(itemsbuf, item_type, it);
2045
2046 if(itemid == -1)
2047 return false;
2048
2049 return game->get_item(itemid);
2050 }
2051 16670498 }
2052
2053
2054 49361017 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2055 {
2056
9/9
✓ Branch 0 taken 2894906 times.
✓ Branch 1 taken 26201769 times.
✓ Branch 2 taken 2894906 times.
✓ Branch 3 taken 2894906 times.
✓ Branch 4 taken 2894906 times.
✓ Branch 5 taken 2894906 times.
✓ Branch 6 taken 2894906 times.
✓ Branch 7 taken 2894906 times.
✓ Branch 8 taken 2894906 times.
49361017 switch(item_type)
2057 {
2058 case itype_clock:
2059 {
2060 2894906 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2061
2062
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2894906 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2894906 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2063 return itemsbuf[maxid].fam_type;
2064
2065 2894906 return has_item(itype_clock,1) ? 1 : 0;
2066 }
2067
2068 case itype_key:
2069 2894906 return game->get_keys();
2070
2071 case itype_lkey:
2072 2894906 return game->lvlkeys[get_dlevel()];
2073
2074 case itype_magiccontainer:
2075 2894906 return game->get_maxmagic()/game->get_mp_per_block();
2076
2077 case itype_triforcepiece:
2078 {
2079 2894906 int32_t count=0;
2080
2081
2/2
✓ Branch 0 taken 1482191872 times.
✓ Branch 1 taken 2894906 times.
1485086778 for(int32_t i=0; i<MAXLEVELS; i++)
2082 {
2083 1482191872 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2084 1482191872 }
2085
2086 2894906 return count;
2087 }
2088
2089 case itype_map:
2090 {
2091 2894906 int32_t count=0;
2092
2093
2/2
✓ Branch 0 taken 1482191872 times.
✓ Branch 1 taken 2894906 times.
1485086778 for(int32_t i=0; i<MAXLEVELS; i++)
2094 {
2095 1482191872 count+=(game->lvlitems[i]&liMAP)?1:0;
2096 1482191872 }
2097
2098 2894906 return count;
2099 }
2100
2101 case itype_compass:
2102 {
2103 2894906 int32_t count=0;
2104
2105
2/2
✓ Branch 0 taken 1482191872 times.
✓ Branch 1 taken 2894906 times.
1485086778 for(int32_t i=0; i<MAXLEVELS; i++)
2106 {
2107 1482191872 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2108 1482191872 }
2109
2110 2894906 return count;
2111 }
2112
2113 case itype_bosskey:
2114 {
2115 2894906 int32_t count=0;
2116
2117
2/2
✓ Branch 0 taken 1482191872 times.
✓ Branch 1 taken 2894906 times.
1485086778 for(int32_t i=0; i<MAXLEVELS; i++)
2118 {
2119 1482191872 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2120 1482191872 }
2121
2122 2894906 return count;
2123 }
2124
2125 default:
2126 26201769 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2127
2128
2/2
✓ Branch 0 taken 5717997 times.
✓ Branch 1 taken 20483772 times.
26201769 if(maxid == -1)
2129 20483772 return 0;
2130
2131 5717997 return itemsbuf[maxid].fam_type;
2132 }
2133 49361017 }
2134
2135 45524710 int32_t current_item(int32_t item_type) //item currently being used
2136 {
2137 45524710 return current_item(item_type, true);
2138 }
2139
2140 26 std::map<int32_t, int32_t> itemcache;
2141
2142 // Not actually used by anything at the moment...
2143 void removeFromItemCache(int32_t itemid)
2144 {
2145 itemcache.erase(itemid);
2146 }
2147
2148 13704 void flushItemCache()
2149 {
2150 13704 itemcache.clear();
2151
2152 //also fix the active subscreen if items were deleted -DD
2153
1/2
✓ Branch 0 taken 13704 times.
✗ Branch 1 not taken.
13704 if(game != NULL)
2154 {
2155 13704 verifyBothWeapons();
2156 13704 load_Sitems(&QMisc);
2157 13704 }
2158 13704 }
2159
2160 // This is used often, so it should be as direct as possible.
2161 1624759527 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2162 {
2163
2/2
✓ Branch 0 taken 1587348970 times.
✓ Branch 1 taken 37410557 times.
1624759527 if(jinx_check)
2164 {
2165
4/4
✓ Branch 0 taken 22892003 times.
✓ Branch 1 taken 14518554 times.
✓ Branch 2 taken 19484977 times.
✓ Branch 3 taken 3407026 times.
37410557 if(!(HeroSwordClk() || HeroItemClk()))
2166 19484977 jinx_check = false; //not jinxed
2167 37410557 }
2168
4/4
✓ Branch 0 taken 1608351881 times.
✓ Branch 1 taken 16407646 times.
✓ Branch 2 taken 17787259 times.
✓ Branch 3 taken 1590564622 times.
1624759527 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2169 {
2170 1590564622 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2171
2172
2/2
✓ Branch 0 taken 1583569037 times.
✓ Branch 1 taken 6995585 times.
1590564622 if(res != itemcache.end())
2173 1583569037 return res->second;
2174 6995585 }
2175
2176 41190490 int32_t result = -1;
2177 41190490 int32_t highestlevel = -1;
2178
2179
2/2
✓ Branch 0 taken 10544765440 times.
✓ Branch 1 taken 41190490 times.
10585955930 for(int32_t i=0; i<MAXITEMS; i++)
2180 {
2181
5/6
✓ Branch 0 taken 819828827 times.
✓ Branch 1 taken 9724936613 times.
✓ Branch 2 taken 11991275 times.
✓ Branch 3 taken 807837552 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11991275 times.
10544765440 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2182 {
2183
4/4
✓ Branch 0 taken 3063969 times.
✓ Branch 1 taken 8927306 times.
✓ Branch 2 taken 940739 times.
✓ Branch 3 taken 11050536 times.
11991275 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2184 {
2185 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2186
2/2
✓ Branch 0 taken 11050428 times.
✓ Branch 1 taken 108 times.
11050536 if(!checkmagiccost(i))
2187 {
2188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2189 }
2190 11050428 }
2191
6/6
✓ Branch 0 taken 10156332 times.
✓ Branch 1 taken 1834835 times.
✓ Branch 2 taken 181578 times.
✓ Branch 3 taken 1653257 times.
✓ Branch 4 taken 1165339 times.
✓ Branch 5 taken 669496 times.
11991167 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2192 {
2193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669496 times.
669496 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2194 669496 continue;
2195 }
2196
2197
2/2
✓ Branch 0 taken 178435 times.
✓ Branch 1 taken 11143236 times.
11321671 if(itemsbuf[i].fam_type >= highestlevel)
2198 {
2199 11143236 highestlevel = itemsbuf[i].fam_type;
2200 11143236 result=i;
2201 11143236 }
2202 11321671 }
2203 10544095836 }
2204
2205
2/2
✓ Branch 0 taken 17925580 times.
✓ Branch 1 taken 23264910 times.
41190490 if(!jinx_check) //Can't cache jinx_check results
2206 23264910 itemcache[itemtype] = result;
2207 41190490 return result;
2208 1624759527 }
2209
2210 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2211 1607074962 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2212 {
2213 1607074962 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2214
2/2
✓ Branch 0 taken 19725992 times.
✓ Branch 1 taken 1587348970 times.
1607074962 if(!jinx_check) //If not already a jinx-immune-only check...
2215 {
2216 //And the player IS jinxed...
2217
4/4
✓ Branch 0 taken 1573021769 times.
✓ Branch 1 taken 14327201 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 1569664405 times.
1587348970 if(HeroSwordClk() || HeroItemClk())
2218 {
2219 //Then do a jinx-immune-only check here
2220 17684565 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2221 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2222 //Should NOT need a compat rule, as this should always return -1 in old quests.
2223
2/2
✓ Branch 0 taken 799717 times.
✓ Branch 1 taken 16884848 times.
17684565 if(ret2 > -1) return ret2;
2224 16884848 }
2225 1586549253 }
2226 1606275245 return ret;
2227 1607074962 }
2228 11330297 int32_t current_item_power(int32_t itemtype)
2229 {
2230 11330297 int32_t result = current_item_id(itemtype,true);
2231
2/2
✓ Branch 0 taken 8098893 times.
✓ Branch 1 taken 3231404 times.
11330297 return (result<0) ? 0 : itemsbuf[result].power;
2232 }
2233
2234 5 int32_t heart_container_id()
2235 {
2236
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 for(int32_t i=0; i<MAXITEMS; i++)
2237 {
2238
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 140 times.
145 if(itemsbuf[i].family == itype_heartcontainer)
2239 {
2240 5 return i;
2241 }
2242 140 }
2243 return -1;
2244 5 }
2245
2246 2894906 int32_t item_tile_mod()
2247 {
2248 2894906 int32_t tile=0;
2249
2250
2/2
✓ Branch 0 taken 782398 times.
✓ Branch 1 taken 2112508 times.
2894906 if(game->get_bombs())
2251 {
2252 2112508 int32_t itemid = current_item_id(itype_bomb,false);
2253
3/4
✓ Branch 0 taken 2031449 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2031449 times.
2112508 if(itemid > -1 && checkbunny(itemid))
2254 2031449 tile+=itemsbuf[itemid].ltm;
2255 2112508 }
2256
2257
2/2
✓ Branch 0 taken 2456117 times.
✓ Branch 1 taken 438789 times.
2894906 if(game->get_sbombs())
2258 {
2259 438789 int32_t itemid = current_item_id(itype_sbomb,false);
2260
3/4
✓ Branch 0 taken 437361 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 437361 times.
438789 if(itemid > -1 && checkbunny(itemid))
2261 437361 tile+=itemsbuf[itemid].ltm;
2262 438789 }
2263
2264
2/2
✓ Branch 0 taken 2817637 times.
✓ Branch 1 taken 77269 times.
2894906 if(current_item(itype_clock))
2265 {
2266 77269 int32_t itemid =
2267
1/2
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
77269 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2268 ? iClock
2269 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2270
2/4
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77269 times.
77269 if(itemid > -1 && checkbunny(itemid))
2271 77269 tile+=itemsbuf[itemid].ltm;
2272 77269 }
2273
2274
2/2
✓ Branch 0 taken 2302638 times.
✓ Branch 1 taken 592268 times.
2894906 if(current_item(itype_key))
2275 {
2276 592268 int32_t itemid =
2277
1/2
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
592268 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2278 ? iKey
2279 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2280
2/4
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 592268 times.
592268 if(itemid > -1 && checkbunny(itemid))
2281 592268 tile+=itemsbuf[itemid].ltm;
2282 592268 }
2283
2284
2/2
✓ Branch 0 taken 2735653 times.
✓ Branch 1 taken 159253 times.
2894906 if(current_item(itype_lkey))
2285 {
2286 159253 int32_t itemid =
2287
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2288 ? iLevelKey
2289 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2290
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2291 159253 tile+=itemsbuf[itemid].ltm;
2292 159253 }
2293
2294
2/2
✓ Branch 0 taken 688952 times.
✓ Branch 1 taken 2205954 times.
2894906 if(current_item(itype_map))
2295 {
2296 2205954 int32_t itemid =
2297
2/2
✓ Branch 0 taken 2205168 times.
✓ Branch 1 taken 786 times.
2205954 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2298 ? iMap
2299 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2300
2/4
✓ Branch 0 taken 2205954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2205954 times.
2205954 if(itemid > -1 && checkbunny(itemid))
2301 2205954 tile+=itemsbuf[itemid].ltm;
2302 2205954 }
2303
2304
2/2
✓ Branch 0 taken 606249 times.
✓ Branch 1 taken 2288657 times.
2894906 if(current_item(itype_compass))
2305 {
2306 2288657 int32_t itemid =
2307
2/2
✓ Branch 0 taken 2207598 times.
✓ Branch 1 taken 81059 times.
2288657 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2308 ? iCompass
2309 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2310
2/4
✓ Branch 0 taken 2288657 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2288657 times.
2288657 if(itemid > -1 && checkbunny(itemid))
2311 2288657 tile+=itemsbuf[itemid].ltm;
2312 2288657 }
2313
2314
2/2
✓ Branch 0 taken 1084544 times.
✓ Branch 1 taken 1810362 times.
2894906 if(current_item(itype_bosskey))
2315 {
2316 1810362 int32_t itemid =
2317
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2318 ? iBossKey
2319 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2320
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2321 1810362 tile+=itemsbuf[itemid].ltm;
2322 1810362 }
2323
2324
2/2
✓ Branch 0 taken 2084333 times.
✓ Branch 1 taken 810573 times.
2894906 if(current_item(itype_magiccontainer))
2325 {
2326 810573 int32_t itemid =
2327
2/2
✓ Branch 0 taken 728728 times.
✓ Branch 1 taken 81845 times.
810573 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2328 ? iMagicC
2329 81845 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2330
2/4
✓ Branch 0 taken 810573 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 810573 times.
810573 if(itemid > -1 && checkbunny(itemid))
2331 810573 tile+=itemsbuf[itemid].ltm;
2332 810573 }
2333
2334
2/2
✓ Branch 0 taken 918319 times.
✓ Branch 1 taken 1976587 times.
2894906 if(current_item(itype_triforcepiece))
2335 {
2336 1976587 int32_t itemid =
2337
1/2
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
1976587 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2338 ? iTriforce
2339 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2340
2/4
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1976587 times.
1976587 if(itemid > -1 && checkbunny(itemid))
2341 1976587 tile+=itemsbuf[itemid].ltm;
2342 1976587 }
2343
2344
2/2
✓ Branch 0 taken 2894906 times.
✓ Branch 1 taken 1482191872 times.
1485086778 for(int32_t i=0; i<itype_max; i++)
2345 {
2346
2/2
✓ Branch 0 taken 1431711232 times.
✓ Branch 1 taken 50480640 times.
1482191872 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2347 {
2348
2/2
✓ Branch 0 taken 985950 times.
✓ Branch 1 taken 49494690 times.
50480640 switch(i)
2349 {
2350 case itype_bomb:
2351 case itype_sbomb:
2352 case itype_clock:
2353 case itype_key:
2354 case itype_lkey:
2355 case itype_map:
2356 case itype_compass:
2357 case itype_bosskey:
2358 case itype_magiccontainer:
2359 case itype_triforcepiece:
2360 985950 continue; //already handled
2361 }
2362 49494690 }
2363 1481205922 int32_t itemid = current_item_id(i,false);
2364
2/2
✓ Branch 0 taken 1478311016 times.
✓ Branch 1 taken 2894906 times.
1481205922 if(i == itype_shield)
2365 2894906 itemid = getCurrentShield(false);
2366
2367
3/4
✓ Branch 0 taken 40504193 times.
✓ Branch 1 taken 1440701729 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40504193 times.
1481205922 if(itemid < 0 || !checkbunny(itemid))
2368 1440701729 continue;
2369
2370 40504193 itemdata const& itm = itemsbuf[itemid];
2371
2372
2/2
✓ Branch 0 taken 38184939 times.
✓ Branch 1 taken 2319254 times.
40504193 switch(itm.family)
2373 {
2374 case itype_shield:
2375
1/2
✓ Branch 0 taken 2319254 times.
✗ Branch 1 not taken.
2319254 if(itm.flags & ITEM_FLAG9) //active shield
2376 {
2377 if(!usingActiveShield(itemid))
2378 {
2379 tile+=itm.misc6; //'Inactive PTM'
2380 continue;
2381 }
2382 }
2383 2319254 break;
2384 }
2385
2386 40504193 tile+=itm.ltm;
2387 40504193 }
2388
2389 2894906 return tile;
2390 }
2391
2392 2894906 int32_t bunny_tile_mod()
2393 {
2394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2894906 times.
2894906 if(Hero.BunnyClock())
2395 {
2396 return game->get_bunny_ltm();
2397 }
2398 2894906 return 0;
2399 2894906 }
2400
2401 // Hints are drawn on a separate layer to combo reveals.
2402 12496 void draw_lens_under(BITMAP *dest, bool layer)
2403 {
2404 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2405 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2406 //Lens flag 3: Don't show armos/chest/dive items
2407 //Lens flag 4: Show Raft Paths
2408 //Lens flag 5: Show Invisible Enemies
2409
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12496 times.
✓ Branch 2 taken 6248 times.
✓ Branch 3 taken 6248 times.
12496 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2410
2411 12496 int32_t strike_hint_table[11]=
2412 {
2413 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2414 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2415 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2416 };
2417
2418 // int32_t page = tmpscr->cpage;
2419 {
2420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12496 times.
12496 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2421 // int32_t temptimer=0;
2422 12496 int32_t tempitem, tempweapon=0;
2423 12496 strike_hint=strike_hint_table[strike_hint_counter];
2424
2425
2/2
✓ Branch 0 taken 12119 times.
✓ Branch 1 taken 377 times.
12496 if(strike_hint_timer>32)
2426 {
2427 377 strike_hint_timer=0;
2428 377 strike_hint_counter=((strike_hint_counter+1)%11);
2429 377 }
2430
2431 12496 ++strike_hint_timer;
2432
2433
2/2
✓ Branch 0 taken 2199296 times.
✓ Branch 1 taken 12496 times.
2211792 for(int32_t i=0; i<176; i++)
2434 {
2435 2199296 int32_t x = (i & 15) << 4;
2436 2199296 int32_t y = (i & 0xF0) + playing_field_offset;
2437 2199296 int32_t tempitemx=-16, tempitemy=-16;
2438 2199296 int32_t tempweaponx=-16, tempweapony=-16;
2439
2440
2/2
✓ Branch 0 taken 4398592 times.
✓ Branch 1 taken 2199296 times.
6597888 for(int32_t iter=0; iter<2; ++iter)
2441 {
2442 4398592 int32_t checkflag=0;
2443
2444
2/2
✓ Branch 0 taken 2199296 times.
✓ Branch 1 taken 2199296 times.
4398592 if(iter==0)
2445 {
2446 2199296 checkflag=combobuf[tmpscr->data[i]].flag;
2447 2199296 }
2448 else
2449 {
2450 2199296 checkflag=tmpscr->sflag[i];
2451 }
2452
2453
2/2
✓ Branch 0 taken 4397494 times.
✓ Branch 1 taken 1098 times.
4398592 if(checkflag==mfSTRIKE)
2454 {
2455
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2456 {
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2458 906 }
2459 else
2460 {
2461 192 checkflag = strike_hint;
2462 }
2463 1098 }
2464
2465
19/36
✓ Branch 0 taken 4360200 times.
✓ Branch 1 taken 2638 times.
✓ Branch 2 taken 2808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28392 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
4398592 switch(checkflag)
2466 {
2467 case 0:
2468 case mfZELDA:
2469 case mfPUSHED:
2470 case mfENEMY0:
2471 case mfENEMY1:
2472 case mfENEMY2:
2473 case mfENEMY3:
2474 case mfENEMY4:
2475 case mfENEMY5:
2476 case mfENEMY6:
2477 case mfENEMY7:
2478 case mfENEMY8:
2479 case mfENEMY9:
2480 case mfSINGLE:
2481 case mfSINGLE16:
2482 case mfNOENEMY:
2483 case mfTRAP_H:
2484 case mfTRAP_V:
2485 case mfTRAP_4:
2486 case mfTRAP_LR:
2487 case mfTRAP_UD:
2488 case mfNOGROUNDENEMY:
2489 case mfNOBLOCKS:
2490 case mfSCRIPT1:
2491 case mfSCRIPT2:
2492 case mfSCRIPT3:
2493 case mfSCRIPT4:
2494 case mfSCRIPT5:
2495 case mfSCRIPT6:
2496 case mfSCRIPT7:
2497 case mfSCRIPT8:
2498 case mfSCRIPT9:
2499 case mfSCRIPT10:
2500 case mfSCRIPT11:
2501 case mfSCRIPT12:
2502 case mfSCRIPT13:
2503 case mfSCRIPT14:
2504 case mfSCRIPT15:
2505 case mfSCRIPT16:
2506 case mfSCRIPT17:
2507 case mfSCRIPT18:
2508 case mfSCRIPT19:
2509 case mfSCRIPT20:
2510 case mfPITHOLE:
2511 case mfPITFALLFLOOR:
2512 case mfLAVA:
2513 case mfICE:
2514 case mfICEDAMAGE:
2515 case mfDAMAGE1:
2516 case mfDAMAGE2:
2517 case mfDAMAGE4:
2518 case mfDAMAGE8:
2519 case mfDAMAGE16:
2520 case mfDAMAGE32:
2521 case mfFREEZEALL:
2522 case mfFREZEALLANSFFCS:
2523 case mfFREEZEFFCSOLY:
2524 case mfSCRITPTW1TRIG:
2525 case mfSCRITPTW2TRIG:
2526 case mfSCRITPTW3TRIG:
2527 case mfSCRITPTW4TRIG:
2528 case mfSCRITPTW5TRIG:
2529 case mfSCRITPTW6TRIG:
2530 case mfSCRITPTW7TRIG:
2531 case mfSCRITPTW8TRIG:
2532 case mfSCRITPTW9TRIG:
2533 case mfSCRITPTW10TRIG:
2534 case mfTROWEL:
2535 case mfTROWELNEXT:
2536 case mfTROWELSPECIALITEM:
2537 case mfSLASHPOT:
2538 case mfLIFTPOT:
2539 case mfLIFTORSLASH:
2540 case mfLIFTROCK:
2541 case mfLIFTROCKHEAVY:
2542 case mfDROPITEM:
2543 case mfSPECIALITEM:
2544 case mfDROPKEY:
2545 case mfDROPLKEY:
2546 case mfDROPCOMPASS:
2547 case mfDROPMAP:
2548 case mfDROPBOSSKEY:
2549 case mfSPAWNNPC:
2550 case mfSWITCHHOOK:
2551 case mfSIDEVIEWLADDER:
2552 case mfSIDEVIEWPLATFORM:
2553 case mfNOENEMYSPAWN:
2554 case mfENEMYALL:
2555 case mfNOMIRROR:
2556 case mfUNSAFEGROUND:
2557 case mf168:
2558 case mf169:
2559 case mf170:
2560 case mf171:
2561 case mf172:
2562 case mf173:
2563 case mf174:
2564 case mf175:
2565 case mf176:
2566 case mf177:
2567 case mf178:
2568 case mf179:
2569 case mf180:
2570 case mf181:
2571 case mf182:
2572 case mf183:
2573 case mf184:
2574 case mf185:
2575 case mf186:
2576 case mf187:
2577 case mf188:
2578 case mf189:
2579 case mf190:
2580 case mf191:
2581 case mf192:
2582 case mf193:
2583 case mf194:
2584 case mf195:
2585 case mf196:
2586 case mf197:
2587 case mf198:
2588 case mf199:
2589 case mf200:
2590 case mf201:
2591 case mf202:
2592 case mf203:
2593 case mf204:
2594 case mf205:
2595 case mf206:
2596 case mf207:
2597 case mf208:
2598 case mf209:
2599 case mf210:
2600 case mf211:
2601 case mf212:
2602 case mf213:
2603 case mf214:
2604 case mf215:
2605 case mf216:
2606 case mf217:
2607 case mf218:
2608 case mf219:
2609 case mf220:
2610 case mf221:
2611 case mf222:
2612 case mf223:
2613 case mf224:
2614 case mf225:
2615 case mf226:
2616 case mf227:
2617 case mf228:
2618 case mf229:
2619 case mf230:
2620 case mf231:
2621 case mf232:
2622 case mf233:
2623 case mf234:
2624 case mf235:
2625 case mf236:
2626 case mf237:
2627 case mf238:
2628 case mf239:
2629 case mf240:
2630 case mf241:
2631 case mf242:
2632 case mf243:
2633 case mf244:
2634 case mf245:
2635 case mf246:
2636 case mf247:
2637 case mf248:
2638 case mf249:
2639 case mf250:
2640 case mf251:
2641 case mf252:
2642 case mf253:
2643 case mf254:
2644 case mfEXTENDED:
2645 4360200 break;
2646
2647 case mfPUSHUD:
2648 case mfPUSHLR:
2649 case mfPUSH4:
2650 case mfPUSHU:
2651 case mfPUSHD:
2652 case mfPUSHL:
2653 case mfPUSHR:
2654 case mfPUSHUDNS:
2655 case mfPUSHLRNS:
2656 case mfPUSH4NS:
2657 case mfPUSHUNS:
2658 case mfPUSHDNS:
2659 case mfPUSHLNS:
2660 case mfPUSHRNS:
2661 case mfPUSHUDINS:
2662 case mfPUSHLRINS:
2663 case mfPUSH4INS:
2664 case mfPUSHUINS:
2665 case mfPUSHDINS:
2666 case mfPUSHLINS:
2667 case mfPUSHRINS:
2668
3/4
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
2638 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2669
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2670 {
2671 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2672 }
2673
2674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2638 times.
2638 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2675
3/6
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 1488 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1488 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2638 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2676 {
2677
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 575 times.
1150 if(hints)
2678 {
2679
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 485 times.
575 switch(combobuf[tmpscr->data[i]].type)
2680 {
2681 case cPUSH_HEAVY:
2682 case cPUSH_HW:
2683 48 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2684 48 tempitemx=x, tempitemy=y;
2685
2686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(tempitem>-1)
2687 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2688
2689 48 break;
2690
2691 case cPUSH_HEAVY2:
2692 case cPUSH_HW2:
2693 42 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2694 42 tempitemx=x, tempitemy=y;
2695
2696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(tempitem>-1)
2697 42 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2698
2699 42 break;
2700 }
2701 575 }
2702 1150 }
2703
2704 2638 break;
2705
2706 case mfWHISTLE:
2707 if(hints)
2708 {
2709 tempitem=getItemID(itemsbuf,itype_whistle,1);
2710
2711 if(tempitem<0) break;
2712
2713 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2714 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2715 {
2716 tempitemx=x;
2717 tempitemy=y;
2718 }
2719
2720 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2721 }
2722
2723 break;
2724
2725 //Why is this here?
2726 case mfFAIRY:
2727 case mfMAGICFAIRY:
2728 case mfALLFAIRY:
2729 if(hints)
2730 {
2731 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2732
2733 if(tempitem < 0) break;
2734
2735 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2736 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2737 {
2738 tempitemx=x;
2739 tempitemy=y;
2740 }
2741
2742 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2743 }
2744
2745 break;
2746
2747 case mfBCANDLE:
2748
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2749 {
2750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2751 252 }
2752 else
2753 {
2754 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2755
2756
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2757
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2759
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2760 {
2761 126 tempitemx=x;
2762 126 tempitemy=y;
2763 126 }
2764
2765 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2766 }
2767
2768 504 break;
2769
2770 case mfRCANDLE:
2771 if(!hints)
2772 {
2773 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2774 }
2775 else
2776 {
2777 tempitem=getItemID(itemsbuf,itype_candle,2);
2778
2779 if(tempitem<0) break;
2780
2781 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2782 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2783 {
2784 tempitemx=x;
2785 tempitemy=y;
2786 }
2787
2788 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2789 }
2790
2791 break;
2792
2793 case mfWANDFIRE:
2794 if(!hints)
2795 {
2796 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2797 }
2798 else
2799 {
2800 tempitem=getItemID(itemsbuf,itype_wand,1);
2801
2802 if(tempitem<0) break;
2803
2804 tempweapon=wFire;
2805
2806 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2807 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2808 {
2809 tempitemx=x;
2810 tempitemy=y;
2811 }
2812 else
2813 {
2814 tempweaponx=x;
2815 tempweapony=y;
2816 }
2817
2818 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2819 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2820 }
2821
2822 break;
2823
2824 case mfDINSFIRE:
2825 if(!hints)
2826 {
2827 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2828 }
2829 else
2830 {
2831 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2832
2833 if(tempitem<0) break;
2834
2835 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2836 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2837 {
2838 tempitemx=x;
2839 tempitemy=y;
2840 }
2841
2842 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2843 }
2844
2845 break;
2846
2847 case mfARROW:
2848
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2849 {
2850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2851 732 }
2852 else
2853 {
2854 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2855
2856
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2857
2858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2859
3/6
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2860 {
2861 42 tempitemx=x;
2862 42 tempitemy=y;
2863 42 }
2864
2865 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2866 }
2867
2868 814 break;
2869
2870 case mfSARROW:
2871 if(!hints)
2872 {
2873 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2874 }
2875 else
2876 {
2877 tempitem=getItemID(itemsbuf,itype_arrow,2);
2878
2879 if(tempitem<0) break;
2880
2881 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2882 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2883 {
2884 tempitemx=x;
2885 tempitemy=y;
2886 }
2887
2888 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2889 }
2890
2891 break;
2892
2893 case mfGARROW:
2894 if(!hints)
2895 {
2896 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2897 }
2898 else
2899 {
2900 tempitem=getItemID(itemsbuf,itype_arrow,3);
2901
2902 if(tempitem<0) break;
2903
2904 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2905 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2906 {
2907 tempitemx=x;
2908 tempitemy=y;
2909 }
2910
2911 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2912 }
2913
2914 break;
2915
2916 case mfBOMB:
2917
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
2918 {
2919 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2920 }
2921 else
2922 {
2923 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2924 17 tempweapon = wLitBomb;
2925
2926 //if (tempitem<0) break;
2927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2928
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2929 {
2930 8 tempweaponx=x;
2931 8 tempweapony=y;
2932 8 }
2933
2934 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2935 }
2936
2937 17 break;
2938
2939 case mfSBOMB:
2940
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2941 {
2942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2943 48 }
2944 else
2945 {
2946 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2947 //if (tempitem<0) break;
2948 48 tempweapon = wLitSBomb;
2949
2950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2951
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2952 {
2953 24 tempweaponx=x;
2954 24 tempweapony=y;
2955 24 }
2956
2957 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2958 }
2959
2960 96 break;
2961
2962 case mfARMOS_SECRET:
2963
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
2964 {
2965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2966 12 }
2967 24 break;
2968
2969 case mfBRANG:
2970
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
2971 {
2972 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2973 }
2974 else
2975 {
2976 5 tempitem=getItemID(itemsbuf,itype_brang,1);
2977
2978
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
2979
2980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2981
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2982 {
2983 3 tempitemx=x;
2984 3 tempitemy=y;
2985 3 }
2986
2987 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2988 }
2989
2990 5 break;
2991
2992 case mfMBRANG:
2993 if(!hints)
2994 {
2995 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
2996 }
2997 else
2998 {
2999 tempitem=getItemID(itemsbuf,itype_brang,2);
3000
3001 if(tempitem<0) break;
3002
3003 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3004 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3005 {
3006 tempitemx=x;
3007 tempitemy=y;
3008 }
3009
3010 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3011 }
3012
3013 break;
3014
3015 case mfFBRANG:
3016 if(!hints)
3017 {
3018 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3019 }
3020 else
3021 {
3022 tempitem=getItemID(itemsbuf,itype_brang,3);
3023
3024 if(tempitem<0) break;
3025
3026 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3027 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3028 {
3029 tempitemx=x;
3030 tempitemy=y;
3031 }
3032
3033 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3034 }
3035
3036 break;
3037
3038 case mfWANDMAGIC:
3039 if(!hints)
3040 {
3041 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3042 }
3043 else
3044 {
3045 tempitem=getItemID(itemsbuf,itype_wand,1);
3046
3047 if(tempitem<0) break;
3048
3049 tempweapon=itemsbuf[tempitem].wpn3;
3050
3051 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3052 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3053 {
3054 tempitemx=x;
3055 tempitemy=y;
3056 }
3057 else
3058 {
3059 tempweaponx=x;
3060 tempweapony=y;
3061 --lens_hint_weapon[wMagic][4];
3062
3063 if(lens_hint_weapon[wMagic][4]<-8)
3064 {
3065 lens_hint_weapon[wMagic][4]=8;
3066 }
3067 }
3068
3069 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3070 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3071 }
3072
3073 break;
3074
3075 case mfREFMAGIC:
3076
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3077 {
3078 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3079 }
3080 else
3081 {
3082 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3083
3084
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3085
3086 16 tempweapon=ewMagic;
3087
3088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3089
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3090 {
3091 8 tempitemx=x;
3092 8 tempitemy=y;
3093 8 }
3094 else
3095 {
3096 8 tempweaponx=x;
3097 8 tempweapony=y;
3098
3099
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(lens_hint_weapon[ewMagic][2]==up)
3100 {
3101 1 --lens_hint_weapon[ewMagic][4];
3102 1 }
3103 else
3104 {
3105 7 ++lens_hint_weapon[ewMagic][4];
3106 }
3107
3108
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewMagic][4]>8)
3109 {
3110 lens_hint_weapon[ewMagic][2]=up;
3111 }
3112
3113
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(lens_hint_weapon[ewMagic][4]<=0)
3114 {
3115 2 lens_hint_weapon[ewMagic][2]=down;
3116 2 }
3117 }
3118
3119 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3120 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3121 }
3122
3123 16 break;
3124
3125 case mfREFFIREBALL:
3126
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3127 {
3128 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3129 }
3130 else
3131 {
3132 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3133
3134
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3135
3136 16 tempweapon=ewFireball;
3137
3138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3139
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3140 {
3141 8 tempitemx=x;
3142 8 tempitemy=y;
3143 8 tempweaponx=x;
3144 8 tempweapony=y;
3145 8 ++lens_hint_weapon[ewFireball][3];
3146
3147
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>8)
3148 {
3149 lens_hint_weapon[ewFireball][3]=-8;
3150 lens_hint_weapon[ewFireball][4]=8;
3151 }
3152
3153
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>0)
3154 {
3155 8 ++lens_hint_weapon[ewFireball][4];
3156 8 }
3157 else
3158 {
3159 --lens_hint_weapon[ewFireball][4];
3160 }
3161 8 }
3162
3163 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3164 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3165 }
3166
3167 16 break;
3168
3169 case mfSWORD:
3170
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3171 {
3172 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3173 }
3174 else
3175 {
3176 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3177
3178
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3179
3180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3181
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3182 {
3183 3 tempitemx=x;
3184 3 tempitemy=y;
3185 3 }
3186
3187 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3188 }
3189
3190 7 break;
3191
3192 case mfWSWORD:
3193 if(!hints)
3194 {
3195 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3196 }
3197 else
3198 {
3199 tempitem=getItemID(itemsbuf,itype_sword,2);
3200
3201 if(tempitem<0) break;
3202
3203 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3204 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3205 {
3206 tempitemx=x;
3207 tempitemy=y;
3208 }
3209
3210 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3211 }
3212
3213 break;
3214
3215 case mfMSWORD:
3216 if(!hints)
3217 {
3218 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3219 }
3220 else
3221 {
3222 tempitem=getItemID(itemsbuf,itype_sword,3);
3223
3224 if(tempitem<0) break;
3225
3226 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3227 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3228 {
3229 tempitemx=x;
3230 tempitemy=y;
3231 }
3232
3233 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3234 }
3235
3236 break;
3237
3238 case mfXSWORD:
3239 if(!hints)
3240 {
3241 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3242 }
3243 else
3244 {
3245 tempitem=getItemID(itemsbuf,itype_sword,4);
3246
3247 if(tempitem<0) break;
3248
3249 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3250 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3251 {
3252 tempitemx=x;
3253 tempitemy=y;
3254 }
3255
3256 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3257 }
3258
3259 break;
3260
3261 case mfSWORDBEAM:
3262
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3263 {
3264 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3265 }
3266 else
3267 {
3268 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3269
3270
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3271
3272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3273
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3274 {
3275 8 tempitemx=x;
3276 8 tempitemy=y;
3277 8 }
3278
3279 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3280 }
3281
3282 16 break;
3283
3284 case mfWSWORDBEAM:
3285 if(!hints)
3286 {
3287 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3288 }
3289 else
3290 {
3291 tempitem=getItemID(itemsbuf,itype_sword,2);
3292
3293 if(tempitem<0) break;
3294
3295 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3296 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3297 {
3298 tempitemx=x;
3299 tempitemy=y;
3300 }
3301
3302 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3303 }
3304
3305 break;
3306
3307 case mfMSWORDBEAM:
3308 if(!hints)
3309 {
3310 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3311 }
3312 else
3313 {
3314 tempitem=getItemID(itemsbuf,itype_sword,3);
3315
3316 if(tempitem<0) break;
3317
3318 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3320 {
3321 tempitemx=x;
3322 tempitemy=y;
3323 }
3324
3325 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3326 }
3327
3328 break;
3329
3330 case mfXSWORDBEAM:
3331 if(!hints)
3332 {
3333 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3334 }
3335 else
3336 {
3337 tempitem=getItemID(itemsbuf,itype_sword,4);
3338
3339 if(tempitem<0) break;
3340
3341 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3342 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3343 {
3344 tempitemx=x;
3345 tempitemy=y;
3346 }
3347
3348 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3349 }
3350
3351 break;
3352
3353 case mfHOOKSHOT:
3354
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3355 {
3356 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3357 }
3358 else
3359 {
3360 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3361
3362
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3363
3364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3365
3/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3366 {
3367 9 tempitemx=x;
3368 9 tempitemy=y;
3369 9 }
3370
3371 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3372 }
3373
3374 17 break;
3375
3376 case mfWAND:
3377
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3378 {
3379 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3380 }
3381 else
3382 {
3383 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3384
3385
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3386
3387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3388
3/6
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3389 {
3390 17 tempitemx=x;
3391 17 tempitemy=y;
3392 17 }
3393
3394 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3395 }
3396
3397 35 break;
3398
3399 case mfHAMMER:
3400
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3401 {
3402 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3403 }
3404 else
3405 {
3406 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3407
3408
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3409
3410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3411
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3412 {
3413 8 tempitemx=x;
3414 8 tempitemy=y;
3415 8 }
3416
3417 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3418 }
3419
3420 17 break;
3421
3422 case mfARMOS_ITEM:
3423 case mfDIVE_ITEM:
3424
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3425 {
3426 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3427 2064 }
3428 2064 break;
3429
3430 case 16:
3431 case 17:
3432 case 18:
3433 case 19:
3434 case 20:
3435 case 21:
3436 case 22:
3437 case 23:
3438 case 24:
3439 case 25:
3440 case 26:
3441 case 27:
3442 case 28:
3443 case 29:
3444 case 30:
3445 case 31:
3446
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 1800 times.
2808 if(!hints)
3447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
3600 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3448 1800 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3449
3450 2808 break;
3451 case mfSECRETSNEXT:
3452 if(!hints)
3453 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3454 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3455
3456 break;
3457
3458 case mfSTRIKE:
3459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3460 {
3461 906 goto special;
3462 }
3463 else
3464 {
3465 break;
3466 }
3467
3468 28392 default: goto special;
3469
3470 special:
3471
8/8
✓ Branch 0 taken 14553 times.
✓ Branch 1 taken 14745 times.
✓ Branch 2 taken 465 times.
✓ Branch 3 taken 14088 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8004 times.
29298 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3472 {
3473
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 3274 times.
✓ Branch 3 taken 3275 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3474 {
3475 3274 rectfill(dest,x,y,x+15,y+15,WHITE);
3476 3274 }
3477 6549 }
3478
3479 29298 break;
3480 }
3481 4398592 }
3482 2199296 }
3483
3484
2/2
✓ Branch 0 taken 6248 times.
✓ Branch 1 taken 6248 times.
12496 if(layer)
3485 {
3486
2/2
✓ Branch 0 taken 6140 times.
✓ Branch 1 taken 108 times.
6248 if(tmpscr->door[0]==dWALK)
3487 108 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3488
3489
2/2
✓ Branch 0 taken 6140 times.
✓ Branch 1 taken 108 times.
6248 if(tmpscr->door[1]==dWALK)
3490 108 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3491
3492
1/2
✓ Branch 0 taken 6248 times.
✗ Branch 1 not taken.
6248 if(tmpscr->door[2]==dWALK)
3493 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3494
3495
1/2
✓ Branch 0 taken 6248 times.
✗ Branch 1 not taken.
6248 if(tmpscr->door[3]==dWALK)
3496 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3497
3498
2/2
✓ Branch 0 taken 6224 times.
✓ Branch 1 taken 24 times.
6248 if(tmpscr->door[0]==dBOMB)
3499 {
3500 24 showbombeddoor(dest, 0);
3501 24 }
3502
3503
2/2
✓ Branch 0 taken 6224 times.
✓ Branch 1 taken 24 times.
6248 if(tmpscr->door[1]==dBOMB)
3504 {
3505 24 showbombeddoor(dest, 1);
3506 24 }
3507
3508
1/2
✓ Branch 0 taken 6248 times.
✗ Branch 1 not taken.
6248 if(tmpscr->door[2]==dBOMB)
3509 {
3510 showbombeddoor(dest, 2);
3511 }
3512
3513
1/2
✓ Branch 0 taken 6248 times.
✗ Branch 1 not taken.
6248 if(tmpscr->door[3]==dBOMB)
3514 {
3515 showbombeddoor(dest, 3);
3516 }
3517 6248 }
3518
3519
2/2
✓ Branch 0 taken 10674 times.
✓ Branch 1 taken 1822 times.
12496 if(tmpscr->stairx + tmpscr->stairy)
3520 {
3521
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 911 times.
1822 if(!hints)
3522 {
3523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 911 times.
911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3524 911 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3525 911 }
3526 else
3527 {
3528
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3529 {
3530 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3531 48 int32_t tempitemx=-16;
3532 48 int32_t tempitemy=-16;
3533
3534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3535
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3536 {
3537 tempitemx=tmpscr->stairx;
3538 tempitemy=tmpscr->stairy+playing_field_offset;
3539 }
3540
3541 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3542 48 }
3543 }
3544 1822 }
3545 }
3546 12496 }
3547
3548 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3549
3550 6079 void draw_lens_over()
3551 {
3552 // Oh, what the heck.
3553 static BITMAP *lens_scr = NULL;
3554 static int32_t last_width = -1;
3555 6079 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3556
3557 // Only redraw the circle if the size has changed
3558
2/2
✓ Branch 0 taken 6076 times.
✓ Branch 1 taken 3 times.
6079 if(width != last_width)
3559 {
3560
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_scr == NULL)
3561 {
3562 3 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3563 3 }
3564
3565 3 clear_to_color(lens_scr, BLACK);
3566 3 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3567 3 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3568 3 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3569 3 last_width=width;
3570 3 }
3571
3572 6079 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3573 6079 }
3574
3575 //----------------------------------------------------------------
3576
3577 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3578 {
3579 //recreating a big bitmap every frame is highly sluggish.
3580
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3581 30701 clear_to_color(wavebuf, BLACK);
3582 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3583
3584 int32_t ofs;
3585 // int32_t amplitude=8;
3586 // int32_t wavelength=4;
3587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3588
2/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3589 30701 int32_t amp2=168;
3590
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3591 30701 int32_t i=frame%amp2;
3592
3593
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3594 {
3595
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3596 {
3597 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3598 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3599 }
3600 else
3601 {
3602 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3603 }
3604
3605
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3606 {
3607
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3608 {
3609 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3610 1320388608 }
3611 5157768 }
3612 5157768 }
3613 30701 }
3614
3615 576 void draw_fuzzy(int32_t fuzz)
3616 // draws from right half of scrollbuf to framebuf
3617 {
3618 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3619 byte *start, *si, *di;
3620
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(fuzz<1)
3622 fuzz = 1;
3623
3624 576 xstep = 128%fuzz;
3625
3626
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 456 times.
576 if(xstep > 0)
3627 456 xstep = fuzz-xstep;
3628
3629 576 ystep = 112%fuzz;
3630
3631
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 408 times.
576 if(ystep > 0)
3632 408 ystep = fuzz-ystep;
3633
3634 576 firsty = 1;
3635
3636
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 20784 times.
21360 for(y=0; y<224;)
3637 {
3638 20784 start = &(scrollbuf->line[y][256]);
3639
3640
4/4
✓ Branch 0 taken 20496 times.
✓ Branch 1 taken 129312 times.
✓ Branch 2 taken 129024 times.
✓ Branch 3 taken 20784 times.
149808 for(dy=0; dy<ystep && dy+y<224; dy++)
3641 {
3642 129024 si = start;
3643 129024 di = &(framebuf->line[y+dy][0]);
3644 129024 i = xstep;
3645 129024 firstx = 1;
3646
3647
2/2
✓ Branch 0 taken 33030144 times.
✓ Branch 1 taken 129024 times.
33159168 for(dx=0; dx<256; dx++)
3648 {
3649 33030144 *(di++) = *si;
3650
3651
2/2
✓ Branch 0 taken 27831552 times.
✓ Branch 1 taken 5198592 times.
33030144 if(++i >= fuzz)
3652 {
3653
2/2
✓ Branch 0 taken 5069568 times.
✓ Branch 1 taken 129024 times.
5198592 if(!firstx)
3654 5069568 si += fuzz;
3655 else
3656 {
3657 129024 si += fuzz-xstep;
3658 129024 firstx = 0;
3659 }
3660
3661 5198592 i = 0;
3662 5198592 }
3663 33030144 }
3664 129024 }
3665
3666
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 576 times.
20784 if(!firsty)
3667 20208 y += fuzz;
3668 else
3669 {
3670 576 y += ystep;
3671 576 ystep = fuzz;
3672 576 firsty = 0;
3673 }
3674 }
3675 576 }
3676
3677 4633574 void updatescr(bool allowwavy)
3678 {
3679
4/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 4633548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
4633574 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3680
4/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 4633548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
4633574 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3681
3682
2/2
✓ Branch 0 taken 4607870 times.
✓ Branch 1 taken 25704 times.
4633574 if(toogam)
3683 {
3684 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3685 25704 }
3686
3687
1/2
✓ Branch 0 taken 4633574 times.
✗ Branch 1 not taken.
4633574 if(Showpal)
3688 dump_pal(framebuf);
3689
3690
2/2
✓ Branch 0 taken 4565803 times.
✓ Branch 1 taken 67771 times.
4633574 if(!Playing)
3691 67771 black_opening_count=0;
3692
3693
2/2
✓ Branch 0 taken 4611002 times.
✓ Branch 1 taken 22572 times.
4633574 if(black_opening_count<0) //shape is opening up
3694 {
3695 22572 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3696
3697
2/4
✓ Branch 0 taken 22572 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22572 times.
22572 if(Advance||(!Paused))
3698 {
3699 22572 ++black_opening_count;
3700 22572 }
3701 22572 }
3702
2/2
✓ Branch 0 taken 4601762 times.
✓ Branch 1 taken 9240 times.
4611002 else if(black_opening_count>0) //shape is closing
3703 {
3704 9240 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3705
3706
2/4
✓ Branch 0 taken 9240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9240 times.
9240 if(Advance||(!Paused))
3707 {
3708 9240 --black_opening_count;
3709 9240 }
3710 9240 }
3711
3712
3/4
✓ Branch 0 taken 4602244 times.
✓ Branch 1 taken 31330 times.
✓ Branch 2 taken 4602244 times.
✗ Branch 3 not taken.
4633574 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3713 {
3714 black_opening_shape = bosCIRCLE;
3715 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3716 refreshTints();
3717 refreshpal=true;
3718 }
3719
3720
2/2
✓ Branch 0 taken 4522277 times.
✓ Branch 1 taken 111297 times.
4633574 if(refreshpal)
3721 {
3722 111297 refreshpal=false;
3723 111297 RAMpal[253] = _RGB(0,0,0);
3724 111297 RAMpal[254] = _RGB(63,63,63);
3725 111297 hw_palette = &RAMpal;
3726 111297 update_hw_pal = true;
3727
3728 111297 create_rgb_table(&rgb_table, RAMpal, NULL);
3729 111297 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3730 111297 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3731
3732
2/2
✓ Branch 0 taken 28492032 times.
✓ Branch 1 taken 111297 times.
28603329 for(int32_t q=0; q<PAL_SIZE; q++)
3733 {
3734 28492032 trans_table2.data[0][q] = q;
3735 28492032 trans_table2.data[q][q] = q;
3736 28492032 }
3737 111297 }
3738
3739 4633574 bool clearwavy = (wavy <= 0);
3740
3741
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 4626329 times.
4633574 if(wavy <= 0)
3742 {
3743 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3744 4626329 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3745 4626329 }
3746
3747 4633574 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3748
3749
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 4602623 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
4633574 if(wavy && Playing && allowwavy)
3750 {
3751 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3752 30701 }
3753
3754
2/2
✓ Branch 0 taken 4626329 times.
✓ Branch 1 taken 7245 times.
4633574 if(clearwavy)
3755 4626329 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3756
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3757 7245 wavy--; // Wavy was set by a script. Decrement it.
3758
3759
5/6
✓ Branch 0 taken 4565803 times.
✓ Branch 1 taken 67771 times.
✓ Branch 2 taken 88078 times.
✓ Branch 3 taken 4477725 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88078 times.
4633574 if(Playing && msgpos && !screenscrolling)
3760 {
3761
1/2
✓ Branch 0 taken 88078 times.
✗ Branch 1 not taken.
88078 if(!(msg_bg_display_buf->clip))
3762 88078 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3763
1/2
✓ Branch 0 taken 88078 times.
✗ Branch 1 not taken.
88078 if(!(msg_portrait_display_buf->clip))
3764 88078 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3765
1/2
✓ Branch 0 taken 88078 times.
✗ Branch 1 not taken.
88078 if(!(msg_txt_display_buf->clip))
3766 88078 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3767 88078 }
3768
3769 /*
3770 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3771 {
3772 BITMAP* subBmp = 0;
3773 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3774 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3775 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3776 destroy_bitmap(subBmp);
3777 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3778 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3779 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3780 }
3781 */
3782
3783
2/2
✓ Branch 0 taken 4612313 times.
✓ Branch 1 taken 21261 times.
4633574 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3784
3785
2/2
✓ Branch 0 taken 4612313 times.
✓ Branch 1 taken 21261 times.
4633574 if(nosubscr)
3786 {
3787 21261 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3788 21261 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3789 21261 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3790 21261 }
3791
3792 //TODO: Optimize blit 'overcalls' -Gleeok
3793
2/2
✓ Branch 0 taken 21261 times.
✓ Branch 1 taken 4612313 times.
4633574 BITMAP *source = nosubscr ? panorama : wavybuf;
3794 4633574 blit(source,framebuf,0,0,0,0,256,224);
3795
3796 4633574 update_hw_screen();
3797 4633574 }
3798
3799 //----------------------------------------------------------------
3800
3801 PALETTE sys_pal;
3802
3803 int32_t onGUISnapshot()
3804 {
3805 char buf[200];
3806 int32_t num=0;
3807 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3808 do
3809 {
3810 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3811 }
3812 while(num<99999 && exists(buf));
3813
3814 BITMAP *b = create_bitmap_ex(8,resx,resy);
3815
3816 if(b)
3817 {
3818 if(MenuOpen)
3819 {
3820 //Cannot load game's palette while GUI elements are in focus. -Z
3821 //If there is a way to do this, then I have missed it.
3822 /*
3823 game_pal();
3824 RAMpal[253] = _RGB(0,0,0);
3825 RAMpal[254] = _RGB(63,63,63);
3826 set_palette_range(RAMpal,0,255,false);
3827 memcpy(RAMpal, snappal, sizeof(snappal));
3828 create_rgb_table(&rgb_table, RAMpal, NULL);
3829 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3830 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3831
3832 for(int32_t q=0; q<PAL_SIZE; q++)
3833 {
3834 trans_table2.data[0][q] = q;
3835 trans_table2.data[q][q] = q;
3836 }
3837 */
3838 //ringcolor(false);
3839 //get_palette(RAMpal);
3840 blit(screen,b,0,0,0,0,resx,resy);
3841 //al_trace("Menu Open\n");
3842 //game_pal();
3843 //PALETTE temppal;
3844 //get_palette(temppal);
3845 //system_pal();
3846 save_bitmap(buf,b,sys_pal);
3847 //save_bitmap(buf,b,RAMpal);
3848 //save_bitmap(buf,b,snappal);
3849 }
3850 else
3851 {
3852 blit(screen,b,0,0,0,0,resx,resy);
3853 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3854 }
3855 destroy_bitmap(b);
3856 }
3857
3858 return D_O_K;
3859 }
3860
3861 int32_t onNonGUISnapshot()
3862 {
3863 PALETTE temppal;
3864 get_palette(temppal);
3865 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3866
3867 char buf[200];
3868 int32_t num=0;
3869
3870 do
3871 {
3872 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3873 }
3874 while(num<99999 && exists(buf));
3875
3876 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3877
3878 return D_O_K;
3879 }
3880
3881 int32_t onSnapshot()
3882 {
3883 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3884 {
3885 onGUISnapshot();
3886 }
3887 else
3888 {
3889 onNonGUISnapshot();
3890 }
3891
3892 return D_O_K;
3893 }
3894
3895 int32_t onSaveMapPic()
3896 {
3897 int32_t mapres2 = 0;
3898 char buf[200];
3899 int32_t num=0;
3900 mapscr tmpscr_b[2];
3901 mapscr tmpscr_c[6];
3902 BITMAP* _screen_draw_buffer = NULL;
3903 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3904 set_clip_state(_screen_draw_buffer,1);
3905
3906 for(int32_t i=0; i<6; ++i)
3907 {
3908 tmpscr_c[i] = tmpscr2[i];
3909 tmpscr2[i].zero_memory();
3910
3911 if(i>=2)
3912 {
3913 continue;
3914 }
3915
3916 tmpscr_b[i] = tmpscr[i];
3917 tmpscr[i].zero_memory();
3918 }
3919
3920 do
3921 {
3922 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3923 }
3924 while(num<99999 && exists(buf));
3925
3926 BITMAP* mappic = NULL;
3927
3928
3929 bool done=false, redraw=true;
3930
3931 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3932
3933 if(!mappic)
3934 {
3935 system_pal();
3936 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3937 game_pal();
3938 return D_O_K;;
3939 }
3940
3941 // draw the map
3942 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3943
3944 for(int32_t y=0; y<8; y++)
3945 {
3946 for(int32_t x=0; x<16; x++)
3947 {
3948 if(!displayOnMap(x, y))
3949 {
3950 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3951 }
3952 else
3953 {
3954 int32_t s = (y<<4) + x;
3955 loadscr2(1,s,-1);
3956
3957 for(int32_t i=0; i<6; i++)
3958 {
3959 if(tmpscr[1].layermap[i]<=0)
3960 continue;
3961
3962 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
3963 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
3964 {
3965 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
3966
3967 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
3968 }
3969 }
3970
3971 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3972
3973 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3974
3975 putscr(_screen_draw_buffer,256,0,tmpscr+1);
3976 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
3977
3978 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3979
3980 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
3981 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
3982 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
3983 {
3984 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
3985 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
3986 }
3987 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
3988
3989 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3990
3991 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
3992 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
3993 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
3994 {
3995 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
3996 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
3997 }
3998 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
3999 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4000
4001 }
4002
4003 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4004 }
4005 }
4006
4007 for(int32_t i=0; i<6; ++i)
4008 {
4009 tmpscr2[i]=tmpscr_c[i];
4010
4011 if(i>=2)
4012 {
4013 continue;
4014 }
4015
4016 tmpscr[i]=tmpscr_b[i];
4017 }
4018
4019 save_bitmap(buf,mappic,RAMpal);
4020 destroy_bitmap(mappic);
4021 destroy_bitmap(_screen_draw_buffer);
4022 return D_O_K;
4023 }
4024
4025 /*
4026 int32_t onSaveMapPic()
4027 {
4028 BITMAP* mappic = NULL;
4029 BITMAP* _screen_draw_buffer = NULL;
4030 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4031 int32_t mapres2 = 0;
4032 char buf[20];
4033 int32_t num=0;
4034 set_clip_state(_screen_draw_buffer,1);
4035 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4036
4037 do
4038 {
4039 sprintf(buf, "zelda%03d.png", ++num);
4040 }
4041 while(num<999 && exists(buf));
4042
4043 // if(!mappic) {
4044 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4045
4046 if(!mappic)
4047 {
4048 system_pal();
4049 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4050 game_pal();
4051 return D_O_K;
4052 }
4053
4054 // }
4055
4056 int32_t layermap, layerscreen;
4057 int32_t x2=0;
4058
4059 // draw the map
4060 for(int32_t y=0; y<8; y++)
4061 {
4062 for(int32_t x=0; x<16; x++)
4063 {
4064 int32_t s = (y<<4) + x;
4065
4066 if(!displayOnMap(x, y))
4067 {
4068 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4069 }
4070 else
4071 {
4072 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4073 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4074
4075 for(int32_t k=0; k<4; k++)
4076 {
4077 if(k==2)
4078 {
4079 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4080 }
4081
4082 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4083
4084 if(layermap>-1)
4085 {
4086 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4087
4088 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4089 {
4090 for(int32_t i=0; i<176; i++)
4091 {
4092 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4093 }
4094 }
4095 else
4096 {
4097 for(int32_t i=0; i<176; i++)
4098 {
4099 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4100 }
4101 }
4102 }
4103 }
4104
4105 for(int32_t i=0; i<176; i++)
4106 {
4107 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4108 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4109 {
4110 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4111 }
4112 }
4113
4114 for(int32_t k=4; k<6; k++)
4115 {
4116 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4117
4118 if(layermap>-1)
4119 {
4120 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4121
4122 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4123 {
4124 for(int32_t i=0; i<176; i++)
4125 {
4126 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4127 }
4128 }
4129 else
4130 {
4131 for(int32_t i=0; i<176; i++)
4132 {
4133 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4134 }
4135 }
4136 }
4137 }
4138 }
4139
4140 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4141 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4142 }
4143
4144 }
4145
4146 save_bitmap(buf,mappic,RAMpal);
4147 destroy_bitmap(mappic);
4148 destroy_bitmap(_screen_draw_buffer);
4149 return D_O_K;
4150 }
4151 */
4152
4153 14 void f_Quit(int32_t type)
4154 {
4155
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4156 return;
4157
4158 14 bool from_menu = is_sys_pal;
4159
4160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4161 {
4162 14 music_pause();
4163 14 pause_all_sfx();
4164 14 }
4165 14 enter_sys_pal();
4166 14 clear_keybuf();
4167
4168
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4169 14 replay_poll();
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4171 14 replay_peek_quit();
4172
4173
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4174 switch(type)
4175 {
4176 case qQUIT:
4177 onQuit();
4178 break;
4179
4180 case qRESET:
4181 onReset();
4182 break;
4183
4184 case qEXIT:
4185 onExit();
4186 break;
4187 }
4188
4189
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4190 {
4191 14 kill_sfx();
4192 14 music_stop();
4193 14 exit_sys_pal();
4194 14 update_hw_screen();
4195 14 }
4196 else
4197 {
4198 exit_sys_pal();
4199 if(!from_menu)
4200 {
4201 music_resume();
4202 resume_all_sfx();
4203 }
4204 }
4205
4206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4207 14 show_mouse(NULL);
4208 14 eat_buttons();
4209
4210 14 zc_readrawkey(KEY_ESC);
4211
4212 14 zc_readrawkey(KEY_ENTER);
4213 14 }
4214
4215 //----------------------------------------------------------------
4216
4217 int32_t onNoWalls()
4218 {
4219 cheats_enqueue(Cheat::Walls);
4220 return D_O_K;
4221 }
4222
4223 int32_t onIgnoreSideview()
4224 {
4225 cheats_enqueue(Cheat::IgnoreSideView);
4226 return D_O_K;
4227 }
4228
4229 4633532 int32_t input_idle(bool checkmouse)
4230 {
4231 static int32_t mx, my, mz, mb;
4232
4233
4/6
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1057929 times.
✓ Branch 3 taken 3575603 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1057929 times.
5691461 if(keypressed() || zc_key_pressed() ||
4234
4/8
✓ Branch 0 taken 1057929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1057929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1057929 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1057929 times.
✗ Branch 7 not taken.
1057929 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4235 {
4236 3575603 idle_count = 0;
4237
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3575603 times.
3575603 if(active_count < MAX_ACTIVE)
4239 {
4240 3575603 ++active_count;
4241 3575603 }
4242 3575603 }
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1057929 times.
1057929 else if(idle_count < MAX_IDLE)
4244 {
4245 1057929 ++idle_count;
4246 1057929 active_count = 0;
4247 1057929 }
4248
4249 4633532 mx = mouse_x;
4250 4633532 my = mouse_y;
4251 4633532 mz = mouse_z;
4252 4633532 mb = mouse_b;
4253
4254 4633532 return idle_count;
4255 }
4256
4257 int32_t onGoFast()
4258 {
4259 cheats_enqueue(Cheat::Fast);
4260 return D_O_K;
4261 }
4262
4263 int32_t onKillCheat()
4264 {
4265 cheats_enqueue(Cheat::Kill);
4266 return D_O_K;
4267 }
4268
4269 int32_t onShowLayer0()
4270 {
4271 show_layer_0 = !show_layer_0;
4272 return D_O_K;
4273 }
4274 int32_t onShowLayer1()
4275 {
4276 show_layer_1 = !show_layer_1;
4277 return D_O_K;
4278 }
4279 int32_t onShowLayer2()
4280 {
4281 show_layer_2 = !show_layer_2;
4282 return D_O_K;
4283 }
4284 int32_t onShowLayer3()
4285 {
4286 show_layer_3 = !show_layer_3;
4287 return D_O_K;
4288 }
4289 int32_t onShowLayer4()
4290 {
4291 show_layer_4 = !show_layer_4;
4292 return D_O_K;
4293 }
4294 int32_t onShowLayer5()
4295 {
4296 show_layer_5 = !show_layer_5;
4297 return D_O_K;
4298 }
4299 int32_t onShowLayer6()
4300 {
4301 show_layer_6 = !show_layer_6;
4302 return D_O_K;
4303 }
4304 int32_t onShowLayerO()
4305 {
4306 show_layer_over=!show_layer_over;
4307 return D_O_K;
4308 }
4309 int32_t onShowLayerP()
4310 {
4311 show_layer_push=!show_layer_push;
4312 return D_O_K;
4313 }
4314 int32_t onShowLayerS()
4315 {
4316 show_sprites=!show_sprites;
4317 return D_O_K;
4318 }
4319 int32_t onShowLayerF()
4320 {
4321 show_ffcs=!show_ffcs;
4322 return D_O_K;
4323 }
4324 int32_t onShowLayerW()
4325 {
4326 show_walkflags=!show_walkflags;
4327 return D_O_K;
4328 }
4329 int32_t onShowLayerE()
4330 {
4331 show_effectflags=!show_effectflags;
4332 return D_O_K;
4333 }
4334 int32_t onShowFFScripts()
4335 {
4336 show_ff_scripts=!show_ff_scripts;
4337 return D_O_K;
4338 }
4339 int32_t onShowHitboxes()
4340 {
4341 show_hitboxes=!show_hitboxes;
4342 return D_O_K;
4343 }
4344
4345 int32_t onLightSwitch()
4346 {
4347 cheats_enqueue(Cheat::Light);
4348 return D_O_K;
4349 }
4350
4351 int32_t onGoTo();
4352 int32_t onGoToComplete();
4353
4354 4633532 void syskeys()
4355 {
4356 4633532 update_system_keys();
4357
4358 int32_t oldtitle_version;
4359
4360
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(close_button_quit)
4361 {
4362 close_button_quit=false;
4363 f_Quit(qEXIT);
4364 }
4365
4366 4633532 poll_joystick();
4367
4368
2/10
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4633532 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4633532 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4369 {
4370 oldtitle_version=title_version;
4371 System();
4372 }
4373
4374 4633532 mouse_down=gui_mouse_b();
4375
4376
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(zc_read_system_key(KEY_F1))
4377 {
4378 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4379 {
4380 halt=!halt;
4381 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4382 }
4383 else
4384 {
4385 Throttlefps=!Throttlefps;
4386 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4387 logic_counter=0;
4388 }
4389 }
4390
4391 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4392 /*
4393 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4394 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4395 */
4396
4397
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(zc_read_system_key(KEY_F2))
4398 {
4399 ShowFPS=!ShowFPS;
4400 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4401 }
4402
4403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4633532 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4404
4405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4633532 if(zc_read_system_key(KEY_F4) && Playing)
4406 {
4407 Paused=true;
4408 Advance=true;
4409 }
4410
4411
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(zc_read_system_key(KEY_F6)) onTryQuit();
4412
4413 #ifndef ALLEGRO_MACOSX
4414
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4415
4416
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4417 #else
4418 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4419
4420 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4421 #endif
4422
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4633532 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4423
4424
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if (zc_read_system_key(KEY_F12))
4425 {
4426 onSnapshot();
4427 }
4428
4429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4633532 if(debug_enabled && zc_read_system_key(KEY_TAB))
4430 set_debug(!get_debug());
4431
4432
3/4
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4613062 times.
4633532 if(get_debug() || cheat>=1)
4433 {
4434
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4435 {
4436 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4437
4438 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4439
4440 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4441
4442 if(zc_readkey(KEY_B))
4443 {
4444 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4445 }
4446
4447 if(zc_readkey(KEY_A))
4448 {
4449 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4450 }
4451 }
4452 20470 }
4453
4454
3/4
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4613062 times.
4633532 if(get_debug() || cheat>=2)
4455 {
4456
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4457 {
4458 if(rI())
4459 {
4460 cheats_enqueue(Cheat::Clock);
4461 }
4462 }
4463 20470 }
4464
4465
3/4
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4613062 times.
4633532 if(get_debug() || cheat>=4)
4466 {
4467
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4468 {
4469 if(rF11())
4470 {
4471 cheats_enqueue(Cheat::Walls);
4472 }
4473
4474 if(rQ())
4475 {
4476 cheats_enqueue(Cheat::Fast);
4477 }
4478
4479 if(zc_readkey(KEY_F))
4480 {
4481 cheats_enqueue(Cheat::Freeze);
4482 }
4483
4484 if(zc_readkey(KEY_G)) onGoToComplete();
4485
4486 if(zc_readkey(KEY_0)) onShowLayer0();
4487
4488 if(zc_readkey(KEY_1)) onShowLayer1();
4489
4490 if(zc_readkey(KEY_2)) onShowLayer2();
4491
4492 if(zc_readkey(KEY_3)) onShowLayer3();
4493
4494 if(zc_readkey(KEY_4)) onShowLayer4();
4495
4496 if(zc_readkey(KEY_5)) onShowLayer5();
4497
4498 if(zc_readkey(KEY_6)) onShowLayer6();
4499
4500 //if(zc_readkey(KEY_7)) onShowLayerO();
4501 if(zc_readkey(KEY_7)) onShowLayerF();
4502
4503 if(zc_readkey(KEY_8)) onShowLayerS();
4504
4505 if(zc_readkey(KEY_W)) onShowLayerW();
4506
4507 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4508
4509 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4510
4511 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4512 if(zc_readkey(KEY_O)) onShowLayerO();
4513 if(zc_readkey(KEY_P)) onShowLayerP();
4514 if(zc_readkey(KEY_C)) onShowHitboxes();
4515 if(zc_readkey(KEY_F)) onShowFFScripts();
4516 }
4517 20470 }
4518
4519
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(volkeys)
4520 {
4521 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4522
4523 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4524
4525 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4526
4527 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4528 }
4529
4530
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4633532 if(!get_debug() || !SystemKeys || replay_is_replaying())
4531 4633532 goto bottom;
4532
4533 if(zc_readkey(KEY_D))
4534 {
4535 details = !details;
4536 rectfill(screen,0,0,319,7,BLACK);
4537 rectfill(screen,0,8,31,239,BLACK);
4538 rectfill(screen,288,8,319,239,BLACK);
4539 rectfill(screen,32,232,287,239,BLACK);
4540 }
4541
4542 if(zc_readkey(KEY_P)) Paused=!Paused;
4543
4544 //if(zc_readkey(KEY_P)) centerHero();
4545 if(zc_readkey(KEY_A))
4546 {
4547 Paused=true;
4548 Advance=true;
4549 }
4550
4551 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4552 #ifndef ALLEGRO_MACOSX
4553 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4554
4555 if(zc_readkey(KEY_F7))
4556 {
4557 Matrix(ss_speed, ss_density, 0);
4558 game_pal();
4559 }
4560 #else
4561 // The reason these are different on Mac in the first place is that
4562 // the OS doesn't let us use F9 and F10...
4563 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4564
4565 if(zc_readkey(KEY_F9))
4566 {
4567 Matrix(ss_speed, ss_density, 0);
4568 game_pal();
4569 }
4570 #endif
4571 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4572 {
4573 //change containers
4574 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4575 {
4576 //magic containers
4577 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4578 {
4579 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4580 }
4581 else
4582 {
4583 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4584 }
4585 }
4586 else
4587 {
4588 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4589 {
4590 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4591 }
4592 else
4593 {
4594 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4595 }
4596 }
4597 }
4598
4599 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4600 {
4601 //change containers
4602 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4603 {
4604 //magic containers
4605 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4606 {
4607 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4608 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4609 //heart containers
4610 }
4611 else
4612 {
4613 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4614 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4615 }
4616 }
4617 else
4618 {
4619 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4620 {
4621 game->set_magic(zc_max(game->get_magic()-1,0));
4622 }
4623 else
4624 {
4625 game->set_life(zc_max(game->get_life()-1,0));
4626 }
4627 }
4628 }
4629
4630 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4631
4632 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4633
4634 verifyBothWeapons();
4635
4636 bottom:
4637
4638
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(input_idle(true) > after_time())
4639 {
4640 Matrix(ss_speed, ss_density, 0);
4641 game_pal();
4642 }
4643 4633532 }
4644
4645 26130220 void checkQuitKeys()
4646 {
4647 #ifndef ALLEGRO_MACOSX
4648
1/2
✓ Branch 0 taken 26130220 times.
✗ Branch 1 not taken.
26130220 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4649
4650
1/2
✓ Branch 0 taken 26130220 times.
✗ Branch 1 not taken.
26130220 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4651 #else
4652 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4653
4654 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4655 #endif
4656 26130220 }
4657
4658 61410 bool CheatModifierKeys()
4659 {
4660 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4661 // to trigger cheats.
4662
1/2
✓ Branch 0 taken 61410 times.
✗ Branch 1 not taken.
61410 if (replay_is_replaying())
4663 61410 return false;
4664
4665 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4666 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4667 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4668 {
4669 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4670 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4671 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4672 {
4673 return true;
4674 }
4675 }
4676 return false;
4677 61410 }
4678
4679 //99:05:54, for some reason?
4680 #define OLDMAXTIME 21405240
4681 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4682 #define MAXTIME 1944000000
4683
4684 4633574 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4685 {
4686
2/2
✓ Branch 0 taken 4372163 times.
✓ Branch 1 taken 261411 times.
4633574 if(zcmusic!=NULL)
4687 {
4688 261411 zcmusic_poll();
4689 261411 }
4690
4691 4633574 updatescr(allowwavy);
4692
4693
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4633574 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4633574 times.
4633574 while(Paused && !Advance && !Quit)
4694 {
4695 // have to call this, otherwise we'll get an infinite loop
4696 syskeys();
4697 if(allowF6Script)
4698 {
4699 FFCore.runF6Engine();
4700 }
4701 throttleFPS();
4702
4703 #ifdef _WIN32
4704
4705 if(use_dwm_flush)
4706 {
4707 do_DwmFlush();
4708 }
4709
4710 #endif
4711
4712 // to keep music playing
4713 if(zcmusic!=NULL)
4714 {
4715 zcmusic_poll();
4716 }
4717
4718 update_hw_screen();
4719 }
4720
4721
2/2
✓ Branch 0 taken 4633539 times.
✓ Branch 1 taken 35 times.
4633574 if(Quit)
4722 35 return;
4723
4724
3/4
✓ Branch 0 taken 4565796 times.
✓ Branch 1 taken 67743 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4565796 times.
4633539 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4725 4565796 game->change_time(1);
4726
4727 4633539 Advance=false;
4728
4729
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4633532 times.
4633539 if (replay_is_active())
4730 {
4731
4/4
✓ Branch 0 taken 1112349 times.
✓ Branch 1 taken 3521183 times.
✓ Branch 2 taken 953212 times.
✓ Branch 3 taken 159137 times.
4633532 if (replay_get_version() >= 8 && !load_control_called_this_frame)
4732 159137 replay_peek_input();
4733
4734
2/2
✓ Branch 0 taken 1270456 times.
✓ Branch 1 taken 3363076 times.
4633532 if (replay_get_version() >= 3)
4735 3363076 replay_poll();
4736
4737 // Replay compatability.
4738
4/4
✓ Branch 0 taken 1212880 times.
✓ Branch 1 taken 3420652 times.
✓ Branch 2 taken 1112345 times.
✓ Branch 3 taken 100535 times.
4633532 if (replay_get_version() >= 6 && replay_get_version() < 8)
4739 100535 replay_peek_input();
4740 4633532 }
4741 4633539 load_control_called_this_frame = false;
4742
4743 4633539 poll_keyboard();
4744 4633539 update_keys();
4745
4746 4633539 ++frame;
4747
4748
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4633532 times.
4633539 if (replay_is_replaying())
4749 4633532 replay_do_cheats();
4750 4633539 syskeys();
4751
4752 // The mouse variables can change from the mouse thread at anytime during a frame,
4753 // so save the result at the start so that replaying is consistent.
4754 4633539 script_mouse_x = gui_mouse_x();
4755 4633539 script_mouse_y = gui_mouse_y();
4756 4633539 script_mouse_z = mouse_z;
4757 4633539 script_mouse_b = mouse_b;
4758
4759 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4760 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4761 // approach here means it doesn't matter which call adds the cheat.
4762 4633539 cheats_execute_queued();
4763
4764
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4633532 times.
4633539 if (replay_is_replaying())
4765 4633532 replay_peek_quit();
4766
2/2
✓ Branch 0 taken 4633525 times.
✓ Branch 1 taken 14 times.
4633539 if (GameFlags & GAMEFLAG_TRYQUIT)
4767 14 replay_step_quit(0);
4768
2/2
✓ Branch 0 taken 1467 times.
✓ Branch 1 taken 4632072 times.
4633539 if(allowF6Script)
4769 {
4770 4632072 FFCore.runF6Engine();
4771 4632072 }
4772
2/2
✓ Branch 0 taken 4633398 times.
✓ Branch 1 taken 141 times.
4633539 if (Quit)
4773 141 replay_step_quit(Quit);
4774 // Someday... maybe install a Turbo button here?
4775 4633539 throttleFPS();
4776
4777 #ifdef _WIN32
4778
4779 if(use_dwm_flush)
4780 {
4781 do_DwmFlush();
4782 }
4783
4784 #endif
4785
4786 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4787
2/2
✓ Branch 0 taken 6447 times.
✓ Branch 1 taken 4627092 times.
4633539 if(sfxcleanup)
4788 4627092 sfx_cleanup();
4789 4633574 }
4790
4791 12 void zapout()
4792 {
4793 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4794 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4795
4796 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4797 12 script_drawing_commands.Clear();
4798
4799 // zap out
4800
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=1; i<=24; i++)
4801 {
4802 288 draw_fuzzy(i);
4803 288 advanceframe(true);
4804
4805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4806 {
4807 break;
4808 }
4809 288 }
4810 12 }
4811
4812 12 void zapin()
4813 {
4814 12 FFCore.warpScriptCheck();
4815 12 draw_screen(tmpscr);
4816 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4817 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4818 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4819
4820 // zap out
4821 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4822
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=24; i>=1; i--)
4823 {
4824 288 draw_fuzzy(i);
4825 288 advanceframe(true);
4826
4827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4828 {
4829 break;
4830 }
4831 288 }
4832 12 }
4833
4834
4835 23 void wavyout(bool showhero)
4836 {
4837 23 draw_screen(tmpscr, showhero);
4838 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4839
4840 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4841 23 clear_to_color(wavebuf,0);
4842 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4843
4844 static PALETTE wavepal;
4845
4846 int32_t ofs;
4847 23 int32_t amplitude=8;
4848
4849 23 int32_t wavelength=4;
4850 23 double palpos=0, palstep=4, palstop=126;
4851
4852 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4853
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4854 {
4855
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4856 {
4857 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4858 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4859 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4860 247296 }
4861
4862 966 palpos+=palstep;
4863
4864
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4865 {
4866 966 hw_palette = &wavepal;
4867 966 update_hw_pal = true;
4868 966 }
4869 else
4870 {
4871 hw_palette = &RAMpal;
4872 update_hw_pal = true;
4873 }
4874
4875
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4876 {
4877
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4878 {
4879 41545728 ofs=0;
4880
4881
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4882 {
4883 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4884 10139136 }
4885
4886 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4887 41545728 }
4888 162288 }
4889
4890 966 advanceframe(true);
4891
4892 // animate_combos();
4893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4894 break;
4895 966 }
4896
4897 23 destroy_bitmap(wavebuf);
4898 23 }
4899
4900 23 void wavyin()
4901 {
4902 23 draw_screen(tmpscr);
4903 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4904
4905 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4906 23 clear_to_color(wavebuf,0);
4907 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4908
4909 static PALETTE wavepal;
4910
4911 //Breaks dark rooms.
4912 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4913 /*
4914 loadfullpal();
4915 loadlvlpal(DMaps[currdmap].color);
4916 ringcolor(false);
4917 */
4918 23 refreshpal=false;
4919 int32_t ofs;
4920 23 int32_t amplitude=8;
4921 23 int32_t wavelength=4;
4922 23 double palpos=168, palstep=4, palstop=126;
4923
4924 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4925
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4926 {
4927
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4928 {
4929 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4930 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4931 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4932 247296 }
4933
4934 966 palpos-=palstep;
4935
4936
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4937 {
4938 966 hw_palette = &wavepal;
4939 966 update_hw_pal = true;
4940 966 }
4941 else
4942 {
4943 hw_palette = &RAMpal;
4944 update_hw_pal = true;
4945 }
4946
4947
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4948 {
4949
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4950 {
4951 41545728 ofs=0;
4952
4953
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4954 {
4955 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4956 10386432 }
4957
4958 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4959 41545728 }
4960 162288 }
4961
4962 966 advanceframe(true);
4963 // animate_combos();
4964
4965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4966 break;
4967 966 }
4968
4969 23 destroy_bitmap(wavebuf);
4970 23 }
4971
4972 1252 void blackscr(int32_t fcnt,bool showsubscr)
4973 {
4974 1252 reset_pal_cycling();
4975 1252 script_drawing_commands.Clear();
4976
4977 1252 FFCore.warpScriptCheck();
4978 1252 bool showtime = game->should_show_time();
4979
2/2
✓ Branch 0 taken 1252 times.
✓ Branch 1 taken 37490 times.
38742 while(fcnt>0)
4980 {
4981 37490 clear_bitmap(framebuf);
4982
4983
2/2
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 28130 times.
37490 if(showsubscr)
4984 {
4985 28130 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4986
3/4
✓ Branch 0 taken 28130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 27380 times.
28130 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4987 {
4988 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4989 750 }
4990 28130 }
4991
4992 37490 advanceframe(true);
4993
4994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37490 times.
37490 if(Quit)
4995 break;
4996
4997 37490 --fcnt;
4998 }
4999 1252 }
5000
5001 330 void openscreen(int32_t shape)
5002 {
5003 330 reset_pal_cycling();
5004 330 black_opening_count=0;
5005
5006
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 232 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
330 if(COOLSCROLL || shape>-1)
5007 {
5008 232 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5009 232 return;
5010 }
5011 else
5012 {
5013 98 Hero.setDontDraw(true);
5014 98 show_subscreen_dmap_dots=false;
5015 98 show_subscreen_numbers=false;
5016 // show_subscreen_items=false;
5017 98 show_subscreen_life=false;
5018 }
5019
5020 98 int32_t x=128;
5021
5022 98 FFCore.warpScriptCheck();
5023
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5024 {
5025 7840 draw_screen(tmpscr);
5026 //? draw_screen already draws the subscreen -DD
5027 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5028 7840 x=128-(((i*128/80)/8)*8);
5029
5030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5031 {
5032 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5033 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5034 7840 }
5035
5036 7840 advanceframe(true);
5037
5038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5039 {
5040 break;
5041 }
5042 7840 }
5043
5044 98 Hero.setDontDraw(false);
5045 98 show_subscreen_items=true;
5046 98 show_subscreen_dmap_dots=true;
5047 330 }
5048
5049 void closescreen(int32_t shape)
5050 {
5051 reset_pal_cycling();
5052 black_opening_count=0;
5053
5054 if(COOLSCROLL || shape>-1)
5055 {
5056 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5057 return;
5058 }
5059 else
5060 {
5061 Hero.setDontDraw(true);
5062 show_subscreen_dmap_dots=false;
5063 show_subscreen_numbers=false;
5064 // show_subscreen_items=false;
5065 show_subscreen_life=false;
5066 }
5067
5068 int32_t x=128;
5069
5070 FFCore.warpScriptCheck();
5071 for(int32_t i=79; i>=0; --i)
5072 {
5073 draw_screen(tmpscr);
5074 //? draw_screen already draws the subscreen -DD
5075 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5076 x=128-(((i*128/80)/8)*8);
5077
5078 if(x>0)
5079 {
5080 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5081 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5082 }
5083
5084 advanceframe(true);
5085
5086 if(Quit)
5087 {
5088 break;
5089 }
5090 }
5091
5092 Hero.setDontDraw(false);
5093 show_subscreen_items=true;
5094 show_subscreen_dmap_dots=true;
5095 }
5096
5097 84 int32_t TriforceCount()
5098 {
5099 84 int32_t c=0;
5100
5101
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 84 times.
756 for(int32_t i=1; i<=8; i++)
5102
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 374 times.
1046 if(game->lvlitems[i]&liTRIFORCE)
5103 374 ++c;
5104
5105 84 return c;
5106 }
5107
5108 int32_t onCustomGame()
5109 {
5110 int32_t file = getsaveslot();
5111
5112 if(file < 0)
5113 return D_O_K;
5114
5115 bool ret = (custom_game(file)!=0);
5116 return ret ? D_CLOSE : D_O_K;
5117 }
5118
5119 int32_t onContinue()
5120 {
5121 return D_CLOSE;
5122 }
5123
5124 int32_t onEsc() // Unused?? -L
5125 {
5126 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5127 }
5128
5129 int32_t onVsync()
5130 {
5131 Throttlefps = !Throttlefps;
5132 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5133 return D_O_K;
5134 }
5135
5136 int32_t onWinPosSave()
5137 {
5138 SaveWinPos = !SaveWinPos;
5139 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5140 return D_O_K;
5141 }
5142
5143 int32_t onClickToFreeze()
5144 {
5145 ClickToFreeze = !ClickToFreeze;
5146 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5147 return D_O_K;
5148 }
5149
5150 int32_t OnSaveZCConfig()
5151 {
5152 if(jwin_alert3(
5153 "Save Configuration",
5154 "Are you sure that you wish to save your present configuration settings?",
5155 "This will overwrite your prior settings!",
5156 NULL,
5157 "&Yes",
5158 "&No",
5159 NULL,
5160 'y',
5161 'n',
5162 0,
5163 lfont) == 1)
5164 {
5165 save_game_configs();
5166 return D_O_K;
5167 }
5168 else return D_O_K;
5169 }
5170
5171 int32_t OnnClearQuestDir()
5172 {
5173 if(jwin_alert3(
5174 "Clear Current Directory Cache",
5175 "Are you sure that you wish to clear the current cached directory?",
5176 "This will default the current directory to the ROOT for this instance of ZC Player!",
5177 NULL,
5178 "&Yes",
5179 "&No",
5180 NULL,
5181 'y',
5182 'n',
5183 0,
5184 lfont) == 1)
5185 {
5186 zc_set_config("zeldadx","win_qst_dir","");
5187 flush_config_file();
5188 strcpy(qstdir,"");
5189 #ifdef __EMSCRIPTEN__
5190 em_sync_fs();
5191 #endif
5192 return D_O_K;
5193 }
5194 else return D_O_K;
5195 }
5196
5197
5198 int32_t onConsoleZASM()
5199 {
5200 if ( !zasm_debugger )
5201 {
5202 AlertDialog("WARNING: ZASM Debugger",
5203 "Enabling this will open the ZASM Debugger Console"
5204 "\nThis will likely grind ZC to a halt with lag."
5205 "\nTo make any use of this, it is suggested that you read"
5206 "\nthe documentation for 'void Breakpoint(char[] string);'"
5207 " in 'ZScript_Additions.txt'"
5208 "\nThis is not recommended for normal users,"
5209 " and is only intended for ZC developers,"
5210 "\nor quest developers coding directly in ZASM"
5211 "\nAre you sure that you wish to open the ZASM Debugger?",
5212 [&](bool ret,bool)
5213 {
5214 if(ret)
5215 {
5216 FFCore.ZASMPrint(true);
5217 }
5218 }).show();
5219 return D_O_K;
5220 }
5221 else
5222 {
5223 FFCore.ZASMPrint(false);
5224 return D_O_K;
5225 }
5226 }
5227
5228
5229 int32_t onConsoleZScript()
5230 {
5231 if ( !zscript_debugger )
5232 {
5233 AlertDialog("ZScript Debugger",
5234 "Enabling this will open the ZScript Debugger Console"
5235 "\nThis will display any messages logged by scripts,"
5236 " including script errors."
5237 "\nAre you sure that you wish to open the ZScript Debugger?",
5238 [&](bool ret,bool)
5239 {
5240 if(ret)
5241 {
5242 FFCore.ZScriptConsole(true);
5243 }
5244 }).show();
5245 return D_O_K;
5246 }
5247 else
5248 {
5249 FFCore.ZScriptConsole(false);
5250 return D_O_K;
5251 }
5252 }
5253
5254 int32_t onClrConsoleOnLoad()
5255 {
5256 clearConsoleOnLoad = !clearConsoleOnLoad;
5257 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5258 return D_O_K;
5259 }
5260
5261
5262 int32_t onFrameSkip()
5263 {
5264 FrameSkip = !FrameSkip;
5265 return D_O_K;
5266 }
5267
5268 int32_t onSaveDragResize()
5269 {
5270 SaveDragResize = !SaveDragResize;
5271 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5272 return D_O_K;
5273 }
5274
5275 int32_t onDragAspect()
5276 {
5277 DragAspect = !DragAspect;
5278 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5279 return D_O_K;
5280 }
5281
5282 int32_t onTransLayers()
5283 {
5284 TransLayers = !TransLayers;
5285 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5286 return D_O_K;
5287 }
5288
5289 int32_t onNESquit()
5290 {
5291 NESquit = !NESquit;
5292 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5293 return D_O_K;
5294 }
5295
5296 int32_t onVolKeys()
5297 {
5298 volkeys = !volkeys;
5299 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5300 return D_O_K;
5301 }
5302
5303 int32_t onShowFPS()
5304 {
5305 ShowFPS = !ShowFPS;
5306 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5307 return D_O_K;
5308 }
5309
5310 546756776 bool is_Fkey(int32_t k)
5311 {
5312
2/2
✓ Branch 0 taken 55602384 times.
✓ Branch 1 taken 491154392 times.
546756776 switch(k)
5313 {
5314 case KEY_F1:
5315 case KEY_F2:
5316 case KEY_F3:
5317 case KEY_F4:
5318 case KEY_F5:
5319 case KEY_F6:
5320 case KEY_F7:
5321 case KEY_F8:
5322 case KEY_F9:
5323 case KEY_F10:
5324 case KEY_F11:
5325 case KEY_F12:
5326 55602384 return true;
5327 }
5328
5329 491154392 return false;
5330 546756776 }
5331
5332 void kb_getkey(DIALOG *d)
5333 {
5334 d->flags|=D_SELECTED;
5335
5336 scare_mouse();
5337 jwin_button_proc(MSG_DRAW,d,0);
5338 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5339 // text_mode(vc(11));
5340 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5341 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5342 unscare_mouse();
5343
5344 update_hw_screen(true);
5345
5346 clear_keybuf();
5347 int32_t k = next_press_key();
5348 clear_keybuf();
5349
5350 //shnarf
5351 //47=f1
5352 //59=esc
5353 if(k>0 && k<123 && !((k>46)&&(k<60)))
5354 *((int32_t*)d->dp3) = k;
5355
5356
5357 d->flags&=~D_SELECTED;
5358 }
5359
5360
5361 //Used by all keyboard key settings dialogues.
5362 void kb_clearjoystick(DIALOG *d)
5363 {
5364 d->flags|=D_SELECTED;
5365
5366 scare_mouse();
5367 jwin_button_proc(MSG_DRAW,d,0);
5368 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5369 // text_mode(vc(11));
5370 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5371 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5372 unscare_mouse();
5373
5374 update_hw_screen(true);
5375
5376 clear_keybuf();
5377 int32_t k = next_press_key();
5378 clear_keybuf();
5379
5380 //shnarf
5381 //47=f1
5382 //59=esc
5383 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5384 // *((int32_t*)d->dp3) = k;
5385 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5386
5387
5388 d->flags&=~D_SELECTED;
5389 }
5390
5391 //Clears key to 0.
5392 //Used by all keyboard key settings dialogues.
5393 void kb_clearkey(DIALOG *d)
5394 {
5395 d->flags|=D_SELECTED;
5396
5397 scare_mouse();
5398 jwin_button_proc(MSG_DRAW,d,0);
5399 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5400 // text_mode(vc(11));
5401 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5402 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5403 unscare_mouse();
5404
5405 update_hw_screen(true);
5406
5407 clear_keybuf();
5408 int32_t k = next_press_key();
5409 clear_keybuf();
5410
5411 //shnarf
5412 //47=f1
5413 //59=esc
5414 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5415 // *((int32_t*)d->dp3) = k;
5416 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5417
5418
5419 d->flags&=~D_SELECTED;
5420 }
5421
5422
5423 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5424 {
5425 switch(msg)
5426 {
5427 case MSG_KEY:
5428 case MSG_CLICK:
5429
5430 kb_clearjoystick(d);
5431
5432 while(gui_mouse_b())
5433 {
5434 clear_keybuf();
5435 rest(1);
5436 }
5437
5438 return D_REDRAW;
5439 }
5440
5441 return jwin_button_proc(msg,d,c);
5442 }
5443
5444 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5445 {
5446 switch(msg)
5447 {
5448 case MSG_KEY:
5449 case MSG_CLICK:
5450
5451 kb_getkey(d);
5452
5453 while(gui_mouse_b()) {
5454 clear_keybuf();
5455 rest(1);
5456 }
5457
5458 return D_REDRAW;
5459 }
5460
5461 return jwin_button_proc(msg,d,c);
5462 }
5463
5464 //Only used in keyboard settings dialogues to clear keys.
5465 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5466 {
5467 switch(msg)
5468 {
5469 case MSG_KEY:
5470 case MSG_CLICK:
5471
5472 kb_clearkey(d);
5473
5474 while(gui_mouse_b()) {
5475 clear_keybuf();
5476 rest(1);
5477 }
5478
5479 return D_REDRAW;
5480 }
5481
5482 return jwin_button_proc(msg,d,c);
5483 }
5484
5485 void j_getbtn(DIALOG *d)
5486 {
5487 d->flags|=D_SELECTED;
5488 scare_mouse();
5489 jwin_button_proc(MSG_DRAW,d,0);
5490 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5491 // text_mode(vc(11));
5492 int32_t y = gui_bmp->h/2 - 12;
5493 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5494 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5495 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5496 unscare_mouse();
5497
5498 update_hw_screen(true);
5499
5500 int32_t b = next_press_btn();
5501
5502 if(b>=0)
5503 *((int32_t*)d->dp3) = b;
5504
5505 d->flags&=~D_SELECTED;
5506
5507 if (player)
5508 player->joy_on = TRUE;
5509 }
5510
5511 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5512 {
5513 switch(msg)
5514 {
5515 case MSG_KEY:
5516 case MSG_CLICK:
5517
5518 j_getbtn(d);
5519
5520 while(gui_mouse_b()) {
5521 rest(1);
5522 clear_keybuf();
5523 }
5524
5525 return D_REDRAW;
5526 }
5527
5528 return jwin_button_proc(msg,d,c);
5529 }
5530
5531 //shnarf
5532 const char *key_str[] =
5533 {
5534 "(none) ", "a ", "b ", "c ",
5535 "d ", "e ", "f ", "g ",
5536 "h ", "i ", "j ", "k ",
5537 "l ", "m ", "n ", "o ",
5538 "p ", "q ", "r ", "s ",
5539 "t ", "u ", "v ", "w ",
5540 "x ", "y ", "z ", "0 ",
5541 "1 ", "2 ", "3 ", "4 ",
5542 "5 ", "6 ", "7 ", "8 ",
5543 "9 ", "num 0 ", "num 1 ", "num 2 ",
5544 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5545 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5546 "f2 ", "f3 ", "f4 ", "f5 ",
5547 "f6 ", "f7 ", "f8 ", "f9 ",
5548 "f10 ", "f11 ", "f12 ", "esc ",
5549 "~ ", "- ", "= ", "backspace ",
5550 "tab ", "{ ", "} ", "enter ",
5551 ": ", "quote ", "\\ ", "\\ (2) ",
5552 ", ", ". ", "/ ", "space ",
5553 "insert ", "delete ", "home ", "end ",
5554 "page up ", "page down ", "left ", "right ",
5555 "up ", "down ", "num / ", "num * ",
5556 "num - ", "num + ", "num delete ", "num enter ",
5557 "print screen ", "pause ", "abnt c1 ", "yen ",
5558 "kana ", "convert ", "no convert ", "at ",
5559 "circumflex ", ": (2) ", "kanji ", "num = ",
5560 "back quote ", "; ", "command ", "unknown (0) ",
5561 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5562 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5563 "right shift ", "left control ", "right control", "alt ",
5564 "alt gr ", "left win ", "right win ", "menu ",
5565 "scroll lock ", "number lock ", "caps lock ", "MAX"
5566 };
5567
5568
5569 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5570 //extern int32_t zcmusic_bufsz;
5571
5572 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5573 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5574
5575 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5576 {
5577 //these are here to bypass compiler warnings about unused arguments
5578 c=c;
5579
5580 if(msg==MSG_DRAW)
5581 {
5582 switch(d->w)
5583 {
5584 case 0:
5585 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5586 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5587 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5588 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5589 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5590 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5591 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5592 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5593 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5594 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5595 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5596 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5597 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5598 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5599 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5600 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5601 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5602 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5603 break;
5604
5605 case 1:
5606 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5607 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5608 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5609 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5610 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5611 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5612 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5613 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5614 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5615 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5616 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5617 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5618 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5619 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5620 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5621 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5622 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5623 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5624 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5625 break;
5626
5627 case 2:
5628 sprintf(str_a," %3d",midi_volume);
5629 sprintf(str_b," %3d",digi_volume);
5630 sprintf(str_l," %3d",emusic_volume);
5631 sprintf(str_m," %3dKB",zcmusic_bufsz);
5632 sprintf(str_r," %3d",sfx_volume);
5633 strcpy(str_s,pan_str[pan_style]);
5634 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5635 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5636 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5637 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5638 break;
5639 }
5640 }
5641
5642 return D_O_K;
5643 }
5644
5645 int32_t set_vol(void *dp3, int32_t d2)
5646 {
5647 switch(((int32_t*)dp3)[0])
5648 {
5649 case 0:
5650 midi_volume = zc_min(d2<<3,255);
5651 break;
5652
5653 case 1:
5654 digi_volume = zc_min(d2<<3,255);
5655 break;
5656
5657 case 2:
5658 emusic_volume = zc_min(d2<<3,255);
5659 break;
5660
5661 case 3:
5662 sfx_volume = zc_min(d2<<3,255);
5663 break;
5664 }
5665
5666 scare_mouse();
5667 // text_mode(vc(11));
5668 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5669 unscare_mouse();
5670 return D_O_K;
5671 }
5672
5673 int32_t set_pan(void *dp3, int32_t d2)
5674 {
5675 pan_style = vbound(d2,0,3);
5676 scare_mouse();
5677 // text_mode(vc(11));
5678 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5679 unscare_mouse();
5680 return D_O_K;
5681 }
5682
5683 int32_t set_buf(void *dp3, int32_t d2)
5684 {
5685 scare_mouse();
5686 // text_mode(vc(11));
5687 zcmusic_bufsz = d2 + 1;
5688 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5689 unscare_mouse();
5690 return D_O_K;
5691 }
5692
5693 static int32_t gamepad_btn_list[] =
5694 {
5695 6,
5696 7,8,9,10,11,12,13,14,15,16,17,
5697 18,19,20,21,22,23,24,25,26,27,28,
5698 29,30,31,32,33,34,35,36,37,38,39,
5699 -1
5700 };
5701
5702 static int32_t gamepad_dirs_list[] =
5703 {
5704 40,41,42,43,
5705 44,45,46,47,
5706 48,49,50,51,
5707 52,53,54,55,
5708 56,
5709 -1
5710 };
5711
5712 static TABPANEL gamepad_tabs[] =
5713 {
5714 // (text)
5715 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5716 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5717 { NULL, 0, NULL, 0, NULL }
5718 };
5719
5720 static DIALOG gamepad_dlg[] =
5721 {
5722 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5723 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5724 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5725 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5726 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5727 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5728 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5729 // 6
5730 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5731 // 7
5732 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5733 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5734 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5735 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5736 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5737 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5738 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5739 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5740 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5741 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5742 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5743 // 18
5744 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5745 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5746 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5747 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5748 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5749 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5750 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5751 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5752 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5753 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5754 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5755 // 29
5756 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5757 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5758 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5759 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5760 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5761 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5762 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5763 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5764 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5765 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5766 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5767 // 40
5768 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5769 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5770 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5771 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5772 // 44
5773 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5774 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5775 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5776 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5777 // 48
5778 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5779 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5780 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5781 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5782 // 52
5783 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5784 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5785 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5786 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5787 // 56
5788 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5789 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5790 };
5791
5792 static int32_t keyboard_keys_list[] =
5793 {
5794 6,7,8,9,10,
5795 11,12,13,14,15,16,17,18,19,20,
5796 21,22,23,24,25,26,27,28,29,30,
5797 31,32,33,34,35,36,37,38,39,40,
5798 -1
5799 };
5800
5801 static int32_t keyboard_dirs_list[] =
5802 {
5803 41,42,43,44,
5804 45,46,47,48,
5805 49,50,51,52,
5806 53,54,55,56,
5807 -1
5808 };
5809
5810 static int32_t keyboard_mods_list[] =
5811 {
5812 57,58,59,60,
5813 61,62,63,64,
5814 65,66,67,68,
5815 69,70,71,72,
5816 -1
5817 };
5818
5819 static TABPANEL keyboard_control_tabs[] =
5820 {
5821 // (text)
5822 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5823 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5824 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5825 { NULL, 0, NULL, 0, NULL }
5826 };
5827
5828 static DIALOG keyboard_control_dlg[] =
5829 {
5830 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5831 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5832 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5833 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5834 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5835 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5836 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5837 // Keys
5838 // 6
5839 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5840 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5841 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5842 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5843 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5844 // 11
5845 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5846 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5847 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5848 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5849 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5850 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5851 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5852 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5853 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5854 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5855 // 21
5856 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5857 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5858 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5859 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5860 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5861 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5862 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5863 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5864 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5865 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5866 // 31
5867 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5868 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5869 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5870 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5871 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5872 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5873 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5874 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5875 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5876 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5877 // Dirs
5878 // 41
5879 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5880 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5881 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5882 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5883 // 45
5884 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5885 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5886 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5887 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5888 // 49
5889 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5890 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5891 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5892 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5893 // 53
5894 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5895 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5896 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5897 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5898 // Mods
5899 // 57
5900 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5901 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5902 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5903 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5904 // 61
5905 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5906 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5907 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5908 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5909 // 65
5910 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5911 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5912 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5913 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5914 // 69
5915 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5916 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5917 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5918 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5919 // 73
5920 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5921 };
5922
5923 /*
5924 int32_t midi_dp[3] = {0,147,104};
5925 int32_t digi_dp[3] = {1,147,120};
5926 int32_t pan_dp[3] = {0,147,136};
5927 int32_t buf_dp[3] = {0,147,152};
5928 */
5929 int32_t midi_dp[3] = {0,0,0};
5930 int32_t digi_dp[3] = {1,0,0};
5931 int32_t emus_dp[3] = {2,0,0};
5932 int32_t buf_dp[3] = {0,0,0};
5933 int32_t sfx_dp[3] = {3,0,0};
5934 int32_t pan_dp[3] = {0,0,0};
5935
5936 static DIALOG sound_dlg[] =
5937 {
5938 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5939 26 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5940 26 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5941 26 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5942 26 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5943 26 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5944 26 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5945 26 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5946 26 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5947 26 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5948 26 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5949 // 10
5950 26 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5951 26 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5952 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5953 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5954 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5955 26 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5956 26 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5957 26 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5958 26 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5959 26 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5960 //20
5961 26 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5962 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5963 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5964 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5965 26 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5966 26 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5967 26 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5968 26 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5969 26 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5970 26 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5971 //30
5972 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5973 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5974 26 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5975 26 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5976 };
5977
5978 char zc_builddate[80];
5979 char zc_aboutstr[80];
5980
5981 static DIALOG about_dlg[] =
5982 {
5983 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5984 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5985 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5986 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5987 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5988 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5989 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5990 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5991 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5992 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5993 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5994 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5995 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5996 };
5997
5998
5999 static DIALOG quest_dlg[] =
6000 {
6001 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6002 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6003 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6004 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6005 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6006 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6007 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6008 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6009 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6010 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6011 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6012 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6013 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6014 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6015 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6016 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6017 };
6018
6019 static DIALOG triforce_dlg[] =
6020 {
6021 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6022 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6023 // 1
6024 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6025 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6026 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6027 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6028 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6029 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6030 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6031 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6032 // 9
6033 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6034 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6035 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6036 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6037 };
6038
6039 /*static DIALOG equip_dlg[] =
6040 {
6041 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6042 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6043 // 1
6044 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6045 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6046 // 3
6047 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6048 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6049 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6050 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6051 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6052 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6053 // 9
6054 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6055 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6056 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6057 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6058 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6059 // 14
6060 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6061 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6062 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6063 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6064 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6065 // 19
6066 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6067 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6068 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6069 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6070 // 23
6071 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6072 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6073 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6074 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6075 // 27
6076 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6077 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6078 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6079 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6080 // 31
6081 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6082 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6083 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6084 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6085 // 35
6086 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6087 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6088 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6089 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6090 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6091 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6092 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6093 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6094 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6095 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6096 };
6097
6098 static DIALOG items_dlg[] =
6099 {
6100 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6101 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6102 //1
6103 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6104 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6105 // 3
6106 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6107 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6108 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6109 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6110 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6111 // 8
6112 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6113 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6114 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6115 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6116 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6117 // 13
6118 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6119 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6120 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6121 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6122 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6123 // 18
6124 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6125 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6126 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6127 // 21
6128 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6129 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6130 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6131 // 24
6132 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6133 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6134 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6135 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6136 // 28
6137 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6138 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6139 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6140 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6141 // 32
6142 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6143 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6144 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6145 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6146 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6147 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6148 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6149 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6150 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6151 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6152 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6153 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6154 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6155 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6156 //45
6157 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6158 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6159 };*/
6160
6161
6162
6163 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6164 {
6165 go();
6166 int32_t ret=0;
6167 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6168 comeback();
6169 return ret != 0;
6170 }
6171
6172
6173 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6174 {
6175 if(def!=modulepath)
6176 strcpy(modulepath,def);
6177
6178 if(!usefilename)
6179 {
6180 int32_t i=(int32_t)strlen(modulepath);
6181
6182 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6183 modulepath[i--]=0;
6184 }
6185
6186 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6187 int32_t ret=0;
6188 int32_t sel=0;
6189
6190 if(list==NULL)
6191 {
6192 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6193 }
6194 else
6195 {
6196 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6197 }
6198
6199 return ret!=0;
6200 }
6201
6202 //The Dialogue that loads a ZMOD Module File
6203 int32_t zc_load_zmod_module_file()
6204 {
6205 if ( Playing )
6206 {
6207 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6208 return -1;
6209 }
6210 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6211 return D_CLOSE;
6212
6213 FILE *tempmodule = fopen(modulepath,"r");
6214
6215 if(tempmodule == NULL)
6216 {
6217 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6218 return -1;
6219 }
6220
6221
6222 //Set the module path:
6223 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6224 strcpy(moduledata.module_name, modulepath);
6225 al_trace("New Module Path is: %s \n", moduledata.module_name);
6226 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6227 zcm.init(true); //Load the module values.
6228 moduledata.refresh_title_screen = 1;
6229 // refresh_select_screen = 1;
6230 build_biic_list();
6231 return D_O_K;
6232 }
6233
6234 static DIALOG module_info_dlg[] =
6235 {
6236 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6237
6238
6239 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6240 //1
6241 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6242 //2
6243 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6244 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6245 //4
6246 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6247 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6248 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6249 //7
6250
6251 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6252 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6253 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6254 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6255 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6256 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6257 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6258 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6259 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6260
6261 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6262 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6263 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6264 };
6265
6266 void about_zcplayer_module(const char *prompt,int32_t initialval)
6267 {
6268
6269 module_info_dlg[0].dp2 = lfont;
6270 if ( moduledata.moduletitle[0] != 0 )
6271 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6272
6273 if ( moduledata.moduleauthor[0] != 0 )
6274 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6275
6276 if ( moduledata.moduleinfo0[0] != 0 )
6277 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6278 if ( moduledata.moduleinfo1[0] != 0 )
6279 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6280 if ( moduledata.moduleinfo2[0] != 0 )
6281 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6282 if ( moduledata.moduleinfo3[0] != 0 )
6283 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6284 if ( moduledata.moduleinfo4[0] != 0 )
6285 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6286
6287 char module_date[255];
6288 memset(module_date, 0, sizeof(module_date));
6289 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6290 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6291
6292
6293
6294 char module_vers[255];
6295 memset(module_vers, 0, sizeof(module_vers));
6296 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6297
6298
6299 //sprintf(tilecount,"%d",1);
6300
6301 char module_build[255];
6302 memset(module_build, 0, sizeof(module_build));
6303 if ( moduledata.modbeta )
6304 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6305 else
6306 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6307
6308 module_info_dlg[12].dp = (char*)module_date;
6309 module_info_dlg[13].dp = (char*)module_vers;
6310 module_info_dlg[14].dp = (char*)module_build;
6311
6312 if(is_large)
6313 large_dialog(module_info_dlg);
6314
6315 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6316 jwin_center_dialog(module_info_dlg);
6317
6318
6319 }
6320
6321 int32_t onAbout_ZCP_Module()
6322 {
6323 about_zcplayer_module("About Module (.zmod)", 0);
6324 return D_O_K;
6325 }
6326
6327 //New Modules Menu for 2.55+
6328 static MENU zcmodule_menu[] =
6329 {
6330 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6331 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6332
6333 { NULL, NULL, NULL, 0, NULL }
6334 };
6335
6336 int32_t onToggleRecordingNewSaves()
6337 {
6338 if (zc_get_config("zeldadx", "replay_new_saves", false))
6339 {
6340 zc_set_config("zeldadx", "replay_new_saves", false);
6341 }
6342 else
6343 {
6344 zc_set_config("zeldadx", "replay_new_saves", true);
6345 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6346 NULL,NULL,"OK",NULL,13,27,lfont);
6347 }
6348 return D_O_K;
6349 }
6350
6351 int32_t onToggleSnapshotAllFrames()
6352 {
6353 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6354 return D_O_K;
6355 }
6356
6357 int32_t onStopReplayOrRecord()
6358 {
6359 if (replay_is_replaying())
6360 {
6361 replay_quit();
6362 }
6363 else if (replay_get_mode() == ReplayMode::Record)
6364 {
6365 if (!replay_get_meta_bool("test_mode"))
6366 {
6367 jwin_alert("Recording", "You cannot stop recording a save file.",
6368 NULL,NULL,"OK",NULL,13,27,lfont);
6369 return D_CLOSE;
6370 }
6371
6372 if (jwin_alert("Stop Recording",
6373 "Save replay to disk and stop recording?",
6374 "This will stop the recording.",
6375 NULL,
6376 "Yes","No",13,27,lfont) != 1)
6377 return D_CLOSE;
6378
6379 replay_save();
6380 replay_stop();
6381 }
6382 return D_O_K;
6383 }
6384
6385 static int32_t handle_on_load_replay(ReplayMode mode)
6386 {
6387 if (Playing)
6388 {
6389 if (jwin_alert("Replay - Warning!",
6390 "Loading a replay will exit the current game.",
6391 "All unsaved progress will be lost.",
6392 "Do you wish to continue?",
6393 "Yes","No",13,27,lfont) != 1)
6394 return D_CLOSE;
6395 }
6396
6397 std::string mode_string = replay_mode_to_string(mode);
6398 mode_string[0] = std::toupper(mode_string[0]);
6399
6400 std::string line_1 = "Select a replay file to play back.";
6401 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6402 std::string line_3 = "You can stop the replay and take over manually any time.";
6403 if (mode == ReplayMode::Update)
6404 {
6405 line_1 = "Select a replay file to update.";
6406 line_2 = "WARNING: be sure to back up the zplay file";
6407 line_3 = "and verify that the updated replay works as expected!";
6408 }
6409
6410 if (jwin_alert(mode_string.c_str(),
6411 line_1.c_str(),
6412 line_2.c_str(),
6413 line_3.c_str(),
6414 "OK","Nevermind",13,27,lfont) == 1)
6415 {
6416 char replay_path[2048];
6417 strcpy(replay_path, "replays/");
6418 if (jwin_file_select_ex(
6419 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6420 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6421 return D_CLOSE;
6422
6423 replay_quit();
6424 load_replay_file_deferred(mode, replay_path);
6425 Quit = qRESET;
6426 return D_CLOSE;
6427 }
6428 return D_O_K;
6429 }
6430
6431 int32_t onLoadReplay()
6432 {
6433 return handle_on_load_replay(ReplayMode::Replay);
6434 }
6435
6436 int32_t onLoadReplayAssert()
6437 {
6438 return handle_on_load_replay(ReplayMode::Assert);
6439 }
6440
6441 int32_t onLoadReplayUpdate()
6442 {
6443 return handle_on_load_replay(ReplayMode::Update);
6444 }
6445
6446 int32_t onSaveReplay()
6447 {
6448 if (replay_get_mode() == ReplayMode::Record)
6449 {
6450 if (!replay_get_meta_bool("test_mode"))
6451 {
6452 if (jwin_alert("Save Replay",
6453 "This will save a copy of the replay up to this point.",
6454 "The official replay file will be untouched.",
6455 "Do you wish to continue?",
6456 "Yes","No",13,27,lfont) != 1)
6457 return D_CLOSE;
6458
6459 char replay_path[2048];
6460 strcpy(replay_path, replay_get_replay_path().string().c_str());
6461 if (jwin_file_select_ex(
6462 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6463 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6464 return D_CLOSE;
6465
6466 if (fileexists(replay_path))
6467 {
6468 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6469 NULL,NULL,"OK",NULL,13,27,lfont);
6470 return D_CLOSE;
6471 }
6472
6473 replay_save(replay_path);
6474 }
6475 else
6476 {
6477 replay_save();
6478 }
6479 }
6480 return D_O_K;
6481 }
6482
6483 static MENU replay_menu[] =
6484 {
6485 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6486 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6487 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6488 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6489 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6490 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6491 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6492
6493 { NULL, NULL, NULL, 0, NULL }
6494 };
6495
6496 static DIALOG credits_dlg[] =
6497 {
6498 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6499 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6500 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6501 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6502 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6503 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6504 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6505 };
6506
6507 26 static ListData dmap_list(dmaplist, &font);
6508
6509 static DIALOG goto_dlg[] =
6510 {
6511 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6512 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6513 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6514 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6515 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6516 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6517 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6518 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6519 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6520 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6521 };
6522
6523 int32_t onGoTo()
6524 {
6525 bool music = false;
6526 music = music;
6527 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6528
6529 goto_dlg[0].dp2=lfont;
6530 goto_dlg[4].d2=cheat_goto_dmap;
6531 goto_dlg[6].dp=cheat_goto_screen_str;
6532
6533 clear_keybuf();
6534
6535 if(is_large)
6536 large_dialog(goto_dlg);
6537
6538 if(zc_popup_dialog(goto_dlg,4)==1)
6539 {
6540 // dmap, screen
6541 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6542 };
6543
6544 return D_O_K;
6545 }
6546
6547 int32_t onGoToComplete()
6548 {
6549 if(!Playing)
6550 {
6551 return D_O_K;
6552 }
6553
6554 system_pal();
6555 music_pause();
6556 pause_all_sfx();
6557 show_mouse(screen);
6558 onGoTo();
6559 eat_buttons();
6560
6561 zc_readrawkey(KEY_ESC);
6562
6563 show_mouse(NULL);
6564 game_pal();
6565 music_resume();
6566 resume_all_sfx();
6567 return D_O_K;
6568 }
6569
6570 int32_t onCredits()
6571 {
6572 go();
6573
6574 BITMAP *win = create_bitmap_ex(8,222,110);
6575
6576 if(!win)
6577 return D_O_K;
6578
6579 int32_t c=0;
6580 int32_t l=0;
6581 int32_t ol=-1;
6582 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6583 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6584 PALETTE tmppal;
6585
6586 rti_gui.transparency_index = 1;
6587
6588 clear_to_color(win, rti_gui.transparency_index);
6589 draw_rle_sprite(win,rle,0,0);
6590 credits_dlg[0].dp2=lfont;
6591 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6592 credits_dlg[2].dp = win;
6593
6594 set_palette_range(black_palette,0,127,false);
6595
6596 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6597
6598 BITMAP* old_screen = screen;
6599 BITMAP* gui_bmp = zc_get_gui_bmp();
6600 ASSERT(gui_bmp);
6601 clear_to_color(gui_bmp, rti_gui.transparency_index);
6602 screen = gui_bmp;
6603
6604 while(update_dialog(p))
6605 {
6606 throttleFPS();
6607 ++c;
6608 l = zc_max((c>>1)-30,0);
6609
6610 if(l > rle->h)
6611 l = c = 0;
6612
6613 if(l > rle->h - 112)
6614 l = rle->h - 112;
6615
6616 clear_bitmap(win);
6617 draw_rle_sprite(win,rle,0,0-l);
6618
6619 if(c<=64)
6620 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6621
6622 set_palette_range(tmppal,0,127,false);
6623
6624 if(l!=ol)
6625 {
6626 scare_mouse();
6627 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6628 unscare_mouse();
6629 SCRFIX();
6630 ol=l;
6631 }
6632
6633 update_hw_screen();
6634 }
6635
6636 screen = old_screen;
6637 system_pal();
6638
6639 shutdown_dialog(p);
6640 destroy_bitmap(win);
6641 //comeback();
6642
6643 rti_gui.transparency_index = 0;
6644
6645 return D_O_K;
6646 }
6647
6648 const char *midilist(int32_t index, int32_t *list_size)
6649 {
6650 if(index<0)
6651 {
6652 *list_size=0;
6653
6654 for(int32_t i=0; i<MAXMIDIS; i++)
6655 if(tunes[i].data)
6656 ++(*list_size);
6657
6658 return NULL;
6659 }
6660
6661 int32_t i=0,m=0;
6662
6663 while(m<=index && i<=MAXMIDIS)
6664 {
6665 if(tunes[i].data)
6666 ++m;
6667
6668 ++i;
6669 }
6670
6671 --i;
6672
6673 if(i==MAXMIDIS && m<index)
6674 return "(null)";
6675
6676 return tunes[i].title;
6677 }
6678
6679 /* ------- MIDI info stuff -------- */
6680
6681 char *text;
6682 midi_info *zmi;
6683 bool dialog_running;
6684 bool listening;
6685
6686 void get_info(int32_t index);
6687
6688 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6689 {
6690 int32_t d2 = d->d2;
6691 int32_t ret = jwin_droplist_proc(msg,d,c);
6692
6693 if(d2!=d->d2)
6694 {
6695 get_info(d->d2);
6696 }
6697
6698 return ret;
6699 }
6700
6701 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6702 {
6703 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6704
6705 int32_t ret = jwin_button_proc(msg,d,c);
6706
6707 if(ret == D_CLOSE)
6708 {
6709 // get current midi index
6710 int32_t index = (d+(d->d1))->d2;
6711 int32_t i=0, m=0;
6712
6713 while(m<=index && i<=MAXMIDIS)
6714 {
6715 if(tunes[i].data)
6716 ++m;
6717
6718 ++i;
6719 }
6720
6721 --i;
6722 jukebox(i);
6723 listening = true;
6724 ret = D_O_K;
6725 }
6726
6727 return ret;
6728 }
6729
6730 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6731 {
6732 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6733
6734 int32_t ret = jwin_button_proc(msg,d,c);
6735
6736 if(ret == D_CLOSE)
6737 {
6738 // get current midi index
6739 int32_t index = (d+(d->d1))->d2;
6740 int32_t i=0, m=0;
6741
6742 while(m<=index && i<=MAXMIDIS)
6743 {
6744 if(tunes[i].data)
6745 ++m;
6746
6747 ++i;
6748 }
6749
6750 --i;
6751
6752 // get file name
6753
6754 int32_t sel=0;
6755 //struct ffblk f;
6756 char title[40] = "Save MIDI: ";
6757 char fname[2048];
6758 memset(fname,0,2048);
6759 static EXT_LIST list[] =
6760 {
6761 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6762 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6763 { NULL, NULL }
6764 };
6765
6766 strcpy(title+11, tunes[i].title);
6767 title[39] = '\0';
6768
6769 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6770 goto done;
6771
6772 if(exists(fname))
6773 {
6774 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6775 goto done;
6776 }
6777
6778 // save midi i
6779
6780 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6781 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6782
6783 done:
6784 chop_path(fname);
6785 ret = D_REDRAW;
6786 }
6787
6788 return ret;
6789 }
6790
6791 26 static ListData midi_list(midilist, &font);
6792
6793 static DIALOG midi_dlg[] =
6794 {
6795 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6796 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6797 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6798 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6799 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6800 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6801 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6802 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6803 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6804 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6805 };
6806
6807 void get_info(int32_t index)
6808 {
6809 int32_t i=0, m=0;
6810
6811 while(m<=index && i<=MAXMIDIS)
6812 {
6813 if(tunes[i].data)
6814 ++m;
6815
6816 ++i;
6817 }
6818
6819 --i;
6820
6821 if(i==MAXMIDIS && m<index)
6822 strcpy(text,"(null)");
6823 else
6824 {
6825 get_midi_info((MIDI*)tunes[i].data,zmi);
6826 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6827 }
6828
6829 midi_dlg[0].dp2=lfont;
6830 midi_dlg[3].dp = text;
6831 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6832 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6833
6834 if(dialog_running)
6835 {
6836 scare_mouse();
6837 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6838 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6839 unscare_mouse();
6840 }
6841 }
6842
6843 int32_t onMIDICredits()
6844 {
6845 text = (char*)malloc(4096);
6846 zmi = (midi_info*)malloc(sizeof(midi_info));
6847
6848 if(!text || !zmi)
6849 {
6850 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6851 return D_O_K;
6852 }
6853
6854 bool do_pause_midi = midi_pos >= 0 && currmidi;
6855 auto restore_midi = currmidi;
6856 if(do_pause_midi)
6857 {
6858 paused_midi_pos = midi_pos;
6859 stop_midi();
6860 midi_paused=true;
6861 midi_suspended = midissuspHALTED;
6862 }
6863
6864 midi_dlg[0].dp2=lfont;
6865 midi_dlg[2].d1 = 0;
6866 midi_dlg[2].d2 = 0;
6867 midi_dlg[4].flags = D_EXIT;
6868 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6869
6870 listening = false;
6871 dialog_running=false;
6872 get_info(0);
6873
6874 dialog_running=true;
6875
6876 if(is_large)
6877 large_dialog(midi_dlg);
6878
6879 zc_popup_dialog(midi_dlg,0);
6880 dialog_running=false;
6881
6882 if(listening)
6883 music_stop();
6884
6885 if(do_pause_midi)
6886 {
6887 midi_suspended = midissuspRESUME;
6888 currmidi = restore_midi;
6889 midi_pos = paused_midi_pos;
6890 }
6891
6892 if(text) free(text);
6893 if(zmi) free(zmi);
6894 return D_O_K;
6895 }
6896
6897 int32_t onAbout()
6898 {
6899 char buf1[80]={0};
6900 std::ostringstream oss;
6901 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6902 oss << buf1 << '\n';
6903 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6904 oss << buf1 << '\n';
6905 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6906 oss << buf1 << '\n';
6907 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6908 oss << buf1 << '\n';
6909 sprintf(buf1, "Tag: %s", getReleaseTag());
6910 oss << buf1 << '\n';
6911
6912 InfoDialog("About ZC", oss.str()).show();
6913 return D_O_K;
6914 }
6915
6916 int32_t onQuest()
6917 {
6918 char fname[100];
6919 strcpy(fname, get_filename(qstpath));
6920 quest_dlg[0].dp2=lfont;
6921 quest_dlg[1].dp = fname;
6922
6923 if(QHeader.quest_number==0)
6924 sprintf(str_a,"Custom");
6925 else
6926 sprintf(str_a,"%d",QHeader.quest_number);
6927
6928 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6929
6930 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6931 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6932
6933 if(is_large)
6934 large_dialog(quest_dlg);
6935
6936 zc_popup_dialog(quest_dlg, 0);
6937 return D_O_K;
6938 }
6939
6940 void call_vidmode_dlg();
6941 int32_t onVidMode()
6942 {
6943 call_vidmode_dlg();
6944 return D_O_K;
6945 }
6946
6947 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6948 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6949 //Added an extra statement, so that if the key is cleared to 0, the cleared
6950 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6951
6952 void load_ukeys(int32_t* arr)
6953 {
6954 arr[ukey_a] = Akey;
6955 arr[ukey_b] = Bkey;
6956 arr[ukey_s] = Skey;
6957 arr[ukey_l] = Lkey;
6958 arr[ukey_r] = Rkey;
6959 arr[ukey_p] = Pkey;
6960 arr[ukey_ex1] = Exkey1;
6961 arr[ukey_ex2] = Exkey2;
6962 arr[ukey_ex3] = Exkey3;
6963 arr[ukey_ex4] = Exkey4;
6964 arr[ukey_du] = DUkey;
6965 arr[ukey_dd] = DDkey;
6966 arr[ukey_dl] = DLkey;
6967 arr[ukey_dr] = DRkey;
6968 arr[ukey_mod1a] = cheat_modifier_keys[0];
6969 arr[ukey_mod1b] = cheat_modifier_keys[1];
6970 arr[ukey_mod2a] = cheat_modifier_keys[2];
6971 arr[ukey_mod2b] = cheat_modifier_keys[3];
6972 };
6973
6974 static const char* ukey_names[] = {
6975 "A", "B", "Start", "L", "R", "Map",
6976 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6977 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6978 "Cheat Mod R1", "Cheat Mod R2",
6979 };
6980 std::string get_ukey_name(int32_t k)
6981 {
6982 if (k < num_ukey) return ukey_names[k];
6983 return "";
6984 }
6985
6986 int32_t onKeyboard()
6987 {
6988 int32_t a = Akey;
6989 int32_t b = Bkey;
6990 int32_t s = Skey;
6991 int32_t l = Lkey;
6992 int32_t r = Rkey;
6993 int32_t p = Pkey;
6994 int32_t ex1 = Exkey1;
6995 int32_t ex2 = Exkey2;
6996 int32_t ex3 = Exkey3;
6997 int32_t ex4 = Exkey4;
6998 int32_t du = DUkey;
6999 int32_t dd = DDkey;
7000 int32_t dl = DLkey;
7001 int32_t dr = DRkey;
7002 int32_t mod1a = cheat_modifier_keys[0];
7003 int32_t mod1b = cheat_modifier_keys[1];
7004 int32_t mod2a = cheat_modifier_keys[2];
7005 int32_t mod2b = cheat_modifier_keys[3];
7006 bool done=false;
7007 int32_t ret;
7008
7009 keyboard_control_dlg[0].dp2=lfont;
7010
7011 if(is_large)
7012 large_dialog(keyboard_control_dlg);
7013
7014 while(!done)
7015 {
7016 ret = zc_popup_dialog(keyboard_control_dlg,3);
7017
7018 if(ret==3) // OK
7019 {
7020 int32_t ukeys[num_ukey];
7021 load_ukeys(ukeys);
7022 std::vector<std::string> uniqueError;
7023 for(int32_t q = 0; q < num_ukey; ++q)
7024 {
7025 for(int32_t p = q+1; p < num_ukey; ++p)
7026 {
7027 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7028 {
7029 char buf[64];
7030 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7031 std::string str(buf);
7032 uniqueError.push_back(str);
7033 }
7034 }
7035 }
7036 if(uniqueError.size() == 0)
7037 {
7038 done = true;
7039 save_control_configs(true);
7040 }
7041 else
7042 {
7043 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7044 box_out("Cannot have duplicate keybinds!"); box_eol();
7045 for(std::vector<std::string>::iterator it = uniqueError.begin();
7046 it != uniqueError.end(); ++it)
7047 {
7048 box_out((*it).c_str()); box_eol();
7049 }
7050 box_end(true);
7051 }
7052 /* Old uniqueness check
7053 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7054 bool unique = true;
7055 addToHash(A,unique,keyhash);
7056 addToHash(B,unique,keyhash);
7057 addToHash(S,unique,keyhash);
7058 addToHash(L,unique,keyhash);
7059 addToHash(R,unique,keyhash);
7060 addToHash(P,unique,keyhash);
7061 addToHash(DU,unique,keyhash);
7062 addToHash(DD,unique,keyhash);
7063 addToHash(DL,unique,keyhash);
7064 addToHash(DR,unique,keyhash);
7065
7066 if(keyhash->find(Exkey1) == keyhash->end())
7067 {
7068 (*keyhash)[Exkey1]=true;
7069 }
7070 else
7071 {
7072 if ( Exkey1 != 0 ) unique = false;
7073 }
7074
7075 if(keyhash->find(Exkey2) == keyhash->end())
7076 {
7077 (*keyhash)[Exkey2]=true;
7078 }
7079 else
7080 {
7081 if ( Exkey2 != 0 ) unique = false;
7082 }
7083
7084 if(keyhash->find(Exkey3) == keyhash->end())
7085 {
7086 (*keyhash)[Exkey3]=true;
7087 }
7088 else
7089 {
7090 if ( Exkey3 != 0 ) unique = false;
7091 }
7092
7093 if(keyhash->find(Exkey4) == keyhash->end())
7094 {
7095 (*keyhash)[Exkey4]=true;
7096 }
7097 else
7098 {
7099 if ( Exkey4 != 0 )unique = false;
7100 }
7101 //modifier keys
7102 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7103 {
7104 (*keyhash)[cheat_modifier_keys[0]]=true;
7105 }
7106 else
7107 {
7108 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7109 }
7110 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7111 {
7112 (*keyhash)[cheat_modifier_keys[1]]=true;
7113 }
7114 else
7115 {
7116 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7117 }
7118 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7119 {
7120 (*keyhash)[cheat_modifier_keys[2]]=true;
7121 }
7122 else
7123 {
7124 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7125 }
7126 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7127 {
7128 (*keyhash)[cheat_modifier_keys[3]]=true;
7129 }
7130 else
7131 {
7132 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7133 }
7134
7135 delete keyhash;
7136
7137 if(unique)
7138 done=true;
7139 else
7140 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7141 */
7142 }
7143 else // Cancel
7144 {
7145 Akey = a;
7146 Bkey = b;
7147 Skey = s;
7148 Lkey = l;
7149 Rkey = r;
7150 Pkey = p;
7151 Exkey1 = ex1;
7152 Exkey2 = ex2;
7153 Exkey3 = ex3;
7154 Exkey4 = ex4;
7155 DUkey = du;
7156 DDkey = dd;
7157 DLkey = dl;
7158 DRkey = dr;
7159 cheat_modifier_keys[0] = mod1a;
7160 cheat_modifier_keys[1] = mod1b;
7161 cheat_modifier_keys[2] = mod2a;
7162 cheat_modifier_keys[3] = mod2b;
7163
7164 done=true;
7165 }
7166
7167 rest(1);
7168 }
7169
7170 return D_O_K;
7171 }
7172
7173 int32_t onGamepad()
7174 {
7175 int32_t a = Abtn;
7176 int32_t b = Bbtn;
7177 int32_t s = Sbtn;
7178 int32_t l = Lbtn;
7179 int32_t r = Rbtn;
7180 int32_t m = Mbtn;
7181 int32_t p = Pbtn;
7182 int32_t ex1 = Exbtn1;
7183 int32_t ex2 = Exbtn2;
7184 int32_t ex3 = Exbtn3;
7185 int32_t ex4 = Exbtn4;
7186 int32_t up = DUbtn;
7187 int32_t down = DDbtn;
7188 int32_t left = DLbtn;
7189 int32_t right = DRbtn;
7190
7191 gamepad_dlg[0].dp2=lfont;
7192 if(analog_movement)
7193 gamepad_dlg[56].flags|=D_SELECTED;
7194 else
7195 gamepad_dlg[56].flags&=~D_SELECTED;
7196
7197 if(is_large)
7198 large_dialog(gamepad_dlg);
7199
7200 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7201
7202 if(ret == 4) //OK
7203 {
7204 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7205 save_control_configs(false);
7206 }
7207 else //Cancel
7208 {
7209 Abtn = a;
7210 Bbtn = b;
7211 Sbtn = s;
7212 Lbtn = l;
7213 Rbtn = r;
7214 Mbtn = m;
7215 Pbtn = p;
7216 Exbtn1 = ex1;
7217 Exbtn2 = ex2;
7218 Exbtn3 = ex3;
7219 Exbtn4 = ex4;
7220 DUbtn = up;
7221 DDbtn = down;
7222 DLbtn = left;
7223 DRbtn = right;
7224 }
7225
7226 return D_O_K;
7227 }
7228
7229 int32_t onSound()
7230 {
7231 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7232 {
7233 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7234 }
7235 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7236 {
7237 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7238 }
7239 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7240 {
7241 emusic_volume = (int32_t)FFCore.usr_music_volume;
7242 }
7243 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7244 {
7245 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7246 }
7247 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7248 {
7249 pan_style = (int32_t)FFCore.usr_panstyle;
7250 }
7251
7252 int32_t m = midi_volume;
7253 int32_t d = digi_volume;
7254 int32_t e = emusic_volume;
7255 int32_t b = zcmusic_bufsz;
7256 int32_t s = sfx_volume;
7257 int32_t p = pan_style;
7258 pan_style = vbound(pan_style,0,3);
7259
7260 sound_dlg[0].dp2=lfont;
7261
7262 if(is_large)
7263 large_dialog(sound_dlg);
7264
7265 midi_dp[1] = sound_dlg[6].x;
7266 midi_dp[2] = sound_dlg[6].y;
7267 digi_dp[1] = sound_dlg[7].x;
7268 digi_dp[2] = sound_dlg[7].y;
7269 emus_dp[1] = sound_dlg[8].x;
7270 emus_dp[2] = sound_dlg[8].y;
7271 buf_dp[1] = sound_dlg[9].x;
7272 buf_dp[2] = sound_dlg[9].y;
7273 sfx_dp[1] = sound_dlg[10].x;
7274 sfx_dp[2] = sound_dlg[10].y;
7275 pan_dp[1] = sound_dlg[11].x;
7276 pan_dp[2] = sound_dlg[11].y;
7277 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7278 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7279 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7280 sound_dlg[18].d2 = zcmusic_bufsz;
7281 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7282 sound_dlg[20].d2 = pan_style;
7283
7284 int32_t ret = zc_popup_dialog(sound_dlg,1);
7285
7286 if(ret==2)
7287 {
7288 master_volume(digi_volume,midi_volume);
7289
7290 for(int32_t i=0; i<WAV_COUNT; ++i)
7291 {
7292 //allegro assertion fails when passing in -1 as voice -DD
7293 if(sfx_voice[i] > 0)
7294 voice_set_volume(sfx_voice[i], sfx_volume);
7295 }
7296 zc_set_config(sfx_sect,"digi",digi_volume);
7297 zc_set_config(sfx_sect,"midi",midi_volume);
7298 zc_set_config(sfx_sect,"sfx",sfx_volume);
7299 zc_set_config(sfx_sect,"emusic",emusic_volume);
7300 zc_set_config(sfx_sect,"pan",pan_style);
7301 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7302 }
7303 else
7304 {
7305 midi_volume = m;
7306 digi_volume = d;
7307 emusic_volume = e;
7308 zcmusic_bufsz = b;
7309 sfx_volume = s;
7310 pan_style = p;
7311 }
7312
7313 return D_O_K;
7314 }
7315
7316 int32_t queding(char const* s1, char const* s2, char const* s3)
7317 {
7318 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7319 }
7320
7321 int32_t onQuit()
7322 {
7323 if(Playing)
7324 {
7325 int32_t ret=0;
7326
7327 if(get_bit(quest_rules, qr_NOCONTINUE))
7328 {
7329 if(standalone_mode)
7330 {
7331 ret=queding("End current game?",
7332 "The continue screen is disabled; the game",
7333 "will be reloaded from the last save.");
7334 }
7335 else
7336 {
7337 ret=queding("End current game?",
7338 "The continue screen is disabled. You will",
7339 "be returned to the file select screen.");
7340 }
7341 }
7342 else
7343 ret=queding("End current game?",NULL,NULL);
7344
7345 if(ret==1)
7346 {
7347 disableClickToFreeze=false;
7348 Quit=qQUIT;
7349
7350 // Trying to evade a door repair charge?
7351 if(repaircharge)
7352 {
7353 game->change_drupy(-repaircharge);
7354 repaircharge=0;
7355 }
7356
7357 return D_CLOSE;
7358 }
7359 }
7360
7361 return D_O_K;
7362 }
7363
7364 int32_t onTryQuitMenu()
7365 {
7366 return onTryQuit(true);
7367 }
7368
7369 int32_t onTryQuit(bool inMenu)
7370 {
7371 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7372 {
7373 if(get_bit(quest_rules,qr_OLD_F6))
7374 {
7375 if(inMenu) onQuit();
7376 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7377 }
7378 else
7379 {
7380 disableClickToFreeze=false;
7381 GameFlags |= GAMEFLAG_TRYQUIT;
7382 }
7383 return D_CLOSE;
7384 }
7385
7386 return D_O_K;
7387 }
7388
7389 int32_t onReset()
7390 {
7391 if(queding(" Reset system? ",NULL,NULL)==1)
7392 {
7393 disableClickToFreeze=false;
7394 Quit=qRESET;
7395 replay_quit();
7396 return D_CLOSE;
7397 }
7398
7399 return D_O_K;
7400 }
7401
7402 int32_t onExit()
7403 {
7404 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7405 {
7406 Quit=qEXIT;
7407 return D_CLOSE;
7408 }
7409
7410 return D_O_K;
7411 }
7412
7413 int32_t onTitle_NES()
7414 {
7415 title_version=0;
7416 zc_set_config(cfg_sect,"title",title_version);
7417 return D_O_K;
7418 }
7419 int32_t onTitle_DX()
7420 {
7421 title_version=1;
7422 zc_set_config(cfg_sect,"title",title_version);
7423 return D_O_K;
7424 }
7425 int32_t onTitle_25()
7426 {
7427 title_version=2;
7428 zc_set_config(cfg_sect,"title",title_version);
7429 return D_O_K;
7430 }
7431
7432 int32_t onDebug()
7433 {
7434 if(debug_enabled)
7435 set_debug(!get_debug());
7436 return D_O_K;
7437 }
7438
7439 int32_t onHeartBeep()
7440 {
7441 heart_beep=!heart_beep;
7442 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7443 return D_O_K;
7444 }
7445
7446 int32_t onSaveIndicator()
7447 {
7448 use_save_indicator=!use_save_indicator;
7449 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7450 return D_O_K;
7451 }
7452
7453 int32_t onEpilepsy()
7454 {
7455 if(jwin_alert3(
7456 "Epilepsy Flash Reduction",
7457 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7458 "Disabling this will restore standard flash and wavy behaviour.",
7459 "Proceed?",
7460 "&Yes",
7461 "&No",
7462 NULL,
7463 'y',
7464 'n',
7465 0,
7466 lfont) == 1)
7467 {
7468 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7469 zc_set_config("zeldadx","checked_epilepsy",1);
7470 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7471 }
7472 return D_O_K;
7473 }
7474
7475 int32_t onTriforce()
7476 {
7477 for(int32_t i=0; i<MAXINITTABS; ++i)
7478 {
7479 init_tabs[i].flags&=~D_SELECTED;
7480 }
7481
7482 init_tabs[3].flags=D_SELECTED;
7483 return onCheatConsole();
7484 /*triforce_dlg[0].dp2=lfont;
7485 for(int32_t i=1; i<=8; i++)
7486 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7487
7488 if(zc_popup_dialog (triforce_dlg,-1)==9)
7489 {
7490 for(int32_t i=1; i<=8; i++)
7491 {
7492 game->lvlitems[i] &= ~liTRIFORCE;
7493 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7494 }
7495 }
7496 return D_O_K;*/
7497 }
7498
7499 bool rc = false;
7500 /*
7501 int32_t onEquipment()
7502 {
7503 for (int32_t i=0; i<MAXINITTABS; ++i)
7504 {
7505 init_tabs[i].flags&=~D_SELECTED;
7506 }
7507 init_tabs[0].flags=D_SELECTED;
7508 return onCheatConsole();
7509 }
7510 */
7511
7512 int32_t onItems()
7513 {
7514 for(int32_t i=0; i<MAXINITTABS; ++i)
7515 {
7516 init_tabs[i].flags&=~D_SELECTED;
7517 }
7518
7519 init_tabs[1].flags=D_SELECTED;
7520 return onCheatConsole();
7521 }
7522
7523 static DIALOG getnum_dlg[] =
7524 {
7525 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7526 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7527 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7528 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7529 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7530 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7531 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7532 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7533 };
7534
7535 int32_t getnumber(const char *prompt,int32_t initialval)
7536 {
7537 char buf[20];
7538 sprintf(buf,"%d",initialval);
7539 getnum_dlg[0].dp=(void *)prompt;
7540 getnum_dlg[0].dp2=lfont;
7541 getnum_dlg[2].dp=buf;
7542
7543 if(is_large)
7544 large_dialog(getnum_dlg);
7545
7546 if(zc_popup_dialog(getnum_dlg,2)==3)
7547 return atoi(buf);
7548
7549 return initialval;
7550 }
7551
7552 int32_t onLife()
7553 {
7554 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7555 cheats_enqueue(Cheat::Life, value);
7556 return D_O_K;
7557 }
7558
7559 int32_t onHeartC()
7560 {
7561 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7562 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7563 cheats_enqueue(Cheat::MaxLife, max_life);
7564 cheats_enqueue(Cheat::Life, life);
7565 return D_O_K;
7566 }
7567
7568 int32_t onMagicC()
7569 {
7570 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7571 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7572 cheats_enqueue(Cheat::MaxMagic, max_magic);
7573 cheats_enqueue(Cheat::Magic, magic);
7574 return D_O_K;
7575 }
7576
7577 int32_t onRupies()
7578 {
7579 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7580 cheats_enqueue(Cheat::Rupies, value);
7581 return D_O_K;
7582 }
7583
7584 int32_t onMaxBombs()
7585 {
7586 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7587 cheats_enqueue(Cheat::MaxBombs, value);
7588 cheats_enqueue(Cheat::Bombs, value);
7589 return D_O_K;
7590 }
7591
7592 int32_t onRefillLife()
7593 {
7594 cheats_enqueue(Cheat::Life, game->get_maxlife());
7595 return D_O_K;
7596 }
7597 int32_t onRefillMagic()
7598 {
7599 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7600 return D_O_K;
7601 }
7602 int32_t onClock()
7603 {
7604 cheats_enqueue(Cheat::Clock);
7605 return D_O_K;
7606 }
7607
7608 int32_t onQstPath()
7609 {
7610 char path[2048];
7611
7612 chop_path(qstdir);
7613 strcpy(path,qstdir);
7614
7615 go();
7616
7617 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7618 {
7619 chop_path(path);
7620 fix_filename_case(path);
7621 fix_filename_slashes(path);
7622 strcpy(qstdir,path);
7623 strcpy(qstpath,qstdir);
7624 }
7625
7626 comeback();
7627 return D_O_K;
7628 }
7629
7630 #include "dialog/cheat_dialog.h"
7631 int32_t onCheat()
7632 {
7633 call_setcheat_dialog();
7634 game->set_cheat(maxcheat);
7635 if(cheat) game->did_cheat(true);
7636 return D_O_K;
7637 }
7638
7639 int32_t onCheatRupies()
7640 {
7641 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7642 return D_O_K;
7643 }
7644
7645 int32_t onCheatArrows()
7646 {
7647 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7648 return D_O_K;
7649 }
7650
7651 int32_t onCheatBombs()
7652 {
7653 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7654 return D_O_K;
7655 }
7656
7657 // *** screen saver
7658
7659 4633532 int32_t after_time()
7660 {
7661
1/2
✓ Branch 0 taken 4633532 times.
✗ Branch 1 not taken.
4633532 if(ss_enable == 0)
7662 return INT_MAX;
7663
7664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
4633532 if(ss_after <= 0)
7665 return 5 * 60;
7666
7667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
4633532 if(ss_after <= 3)
7668 return ss_after * 15 * 60;
7669
7670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4633532 times.
4633532 if(ss_after <= 13)
7671 return (ss_after - 3) * 60 * 60;
7672
7673 4633532 return MAX_IDLE + 1;
7674 4633532 }
7675
7676 static const char *after_str[15] =
7677 {
7678 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7679 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7680 "Never"
7681 };
7682
7683 const char *after_list(int32_t index, int32_t *list_size)
7684 {
7685 if(index < 0)
7686 {
7687 *list_size = 15;
7688 return NULL;
7689 }
7690
7691 return after_str[index];
7692 }
7693
7694 26 static ListData after__list(after_list, &font);
7695
7696 static DIALOG scrsaver_dlg[] =
7697 {
7698 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7699 26 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7700 26 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7701 26 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7702 26 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7703 26 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7704 26 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7705 26 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7706 26 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7707 26 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7708 26 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7709 26 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7710 26 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7711 26 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7712 };
7713
7714 int32_t onScreenSaver()
7715 {
7716 scrsaver_dlg[0].dp2=lfont;
7717 int32_t oldcfgs[3];
7718 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7719 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7720 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7721
7722 if(is_large)
7723 large_dialog(scrsaver_dlg);
7724
7725 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7726
7727 if(ret == 8 || ret == 9)
7728 {
7729 ss_after = scrsaver_dlg[5].d1;
7730 ss_speed = scrsaver_dlg[6].d2;
7731 ss_density = scrsaver_dlg[7].d2;
7732 if(oldcfgs[0] != ss_after)
7733 zc_set_config(cfg_sect,"ss_after",ss_after);
7734 if(oldcfgs[1] != ss_speed)
7735 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7736 if(oldcfgs[2] != ss_density)
7737 zc_set_config(cfg_sect,"ss_density",ss_density);
7738 }
7739
7740 if(ret == 9)
7741 // preview Screen Saver
7742 {
7743 clear_keybuf();
7744 scare_mouse();
7745 Matrix(ss_speed, ss_density, 30);
7746 system_pal();
7747 unscare_mouse();
7748 }
7749
7750 return D_O_K;
7751 }
7752
7753 /***** Menus *****/
7754
7755 static MENU game_menu[] =
7756 {
7757 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7758 { (char *)"", NULL, NULL, 0, NULL },
7759 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7760 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7761 { (char *)"", NULL, NULL, 0, NULL },
7762 #ifdef __EMSCRIPTEN__
7763 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7764 #elif defined(ALLEGRO_MACOSX)
7765 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7766 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7767 #else
7768 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7769 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7770 #endif
7771 { NULL, NULL, NULL, 0, NULL }
7772 };
7773
7774 static MENU title_menu[] =
7775 {
7776 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7777 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7778 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7779 { NULL, NULL, NULL, 0, NULL }
7780 };
7781
7782 static MENU snapshot_format_menu[] =
7783 {
7784 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7785 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7786 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7787 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7788 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7789 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7790 { NULL, NULL, NULL, 0, NULL }
7791 };
7792
7793 static MENU controls_menu[] =
7794 {
7795 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7796 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7797 { NULL, NULL, NULL, 0, NULL }
7798 };
7799
7800 static MENU name_entry_mode_menu[] =
7801 {
7802 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7803 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7804 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7805 { NULL, NULL, NULL, 0, NULL }
7806 };
7807
7808 static void set_controls_menu_active()
7809 {
7810
7811 }
7812
7813 static MENU settings_menu[] =
7814 {
7815 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7816 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7817 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7818 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7819 { (char *)"", NULL, NULL, 0, NULL },
7820 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7821 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7822 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7823 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7824 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7825 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7826 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7827 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7828 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7829 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7830 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7831 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7832 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7833 { (char *)"", NULL, NULL, 0, NULL },
7834 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7835 { (char *)"", NULL, NULL, 0, NULL },
7836 { NULL, NULL, NULL, 0, NULL }
7837 };
7838
7839
7840 static MENU misc_menu[] =
7841 {
7842 { (char *)"&About...", onAbout, NULL, 0, NULL },
7843 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7844 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7845 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7846 { (char *)"", NULL, NULL, 0, NULL },
7847 //5
7848 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7849 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7850 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7851 { (char *)"", NULL, NULL, 0, NULL },
7852 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7853 //10
7854 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7855 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7856 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7857 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7858 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7859 //15
7860 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7861 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7862 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7863
7864 { NULL, NULL, NULL, 0, NULL }
7865 };
7866
7867 static MENU refill_menu[] =
7868 {
7869 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7870 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7871 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7872 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7873 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7874 { NULL, NULL, NULL, 0, NULL }
7875 };
7876
7877 static MENU show_menu[] =
7878 {
7879 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7880 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7881 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7882 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7883 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7884 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7885 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7886 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7887 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7888 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7889 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7890 { (char *)"", NULL, NULL, 0, NULL },
7891 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7892 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7893 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7894 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7895 { NULL, NULL, NULL, 0, NULL }
7896 };
7897
7898 static MENU cheat_menu[] =
7899 {
7900 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7901 { (char *)"", NULL, NULL, 0, NULL },
7902 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7903 { (char *)"", NULL, NULL, 0, NULL },
7904 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7905 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7906 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7907 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7908 { (char *)"", NULL, NULL, 0, NULL },
7909 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7910 { (char *)"", NULL, NULL, 0, NULL },
7911 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7912 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7913 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7914 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7915 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7916 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7917 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7918 { NULL, NULL, NULL, 0, NULL }
7919 };
7920
7921 static MENU fixes_menu[] =
7922 {
7923 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7924 { NULL, NULL, NULL, 0, NULL }
7925 };
7926
7927 #if DEVLEVEL > 0
7928 int32_t devLogging();
7929 int32_t devDebug();
7930 int32_t devTimestmp();
7931 #if DEVLEVEL > 1
7932 int32_t setCheat();
7933 #endif //DEVLEVEL > 1
7934 enum
7935 {
7936 dv_log,
7937 // dv_dbg,
7938 dv_tmpstmp,
7939 #if DEVLEVEL > 1
7940 dv_nil,
7941 dv_setcheat,
7942 #endif //DEVLEVEL > 1
7943 dv_max
7944 };
7945 static MENU dev_menu[] =
7946 {
7947 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7948 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7949 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7950 #if DEVLEVEL > 1
7951 { (char *)"", NULL, NULL, 0, NULL },
7952 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7953 #endif //DEVLEVEL > 1
7954 { NULL, NULL, NULL, 0, NULL }
7955 };
7956 int32_t devLogging()
7957 {
7958 dev_logging = !dev_logging;
7959 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7960 return D_O_K;
7961 }
7962 // int32_t devDebug()
7963 // {
7964 // dev_debug = !dev_debug;
7965 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7966 // return D_O_K;
7967 // }
7968 int32_t devTimestmp()
7969 {
7970 dev_timestmp = !dev_timestmp;
7971 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7972 return D_O_K;
7973 }
7974 #if DEVLEVEL > 1
7975 int32_t setCheat()
7976 {
7977 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7978 return D_O_K;
7979 }
7980 #endif //DEVLEVEL > 1
7981 #endif //DEVLEVEL > 0
7982
7983 MENU the_player_menu[] =
7984 {
7985 { (char *)"&Game", NULL, game_menu, 0, NULL },
7986 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7987 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7988 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7989 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7990 #if DEVLEVEL > 0
7991 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7992 #endif
7993 { NULL, NULL, NULL, 0, NULL }
7994 };
7995
7996 MENU the_player_menu2[] =
7997 {
7998 { (char *)"&Game", NULL, game_menu, 0, NULL },
7999 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8000 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8001 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8002 #if DEVLEVEL > 0
8003 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8004 #endif
8005 { NULL, NULL, NULL, 0, NULL }
8006 };
8007
8008 int32_t onMIDIPatch()
8009 {
8010 if(jwin_alert3(
8011 "Toggle Windows MIDI Fix",
8012 "This action will change whether ZC Player auto-restarts a MIDI at its",
8013 "last index if you move ZC Player out of focus, then back into focus.",
8014 "Proceed?",
8015 "&Yes",
8016 "&No",
8017 NULL,
8018 'y',
8019 'n',
8020 0,
8021 lfont) == 1)
8022 {
8023 midi_patch_fix = midi_patch_fix ? 0 : 1;
8024 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8025 }
8026 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8027 return D_O_K;
8028 }
8029
8030 int32_t onKeyboardEntry()
8031 {
8032 NameEntryMode=0;
8033 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8034 return D_O_K;
8035 }
8036
8037 int32_t onLetterGridEntry()
8038 {
8039 NameEntryMode=1;
8040 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8041 return D_O_K;
8042 }
8043
8044 int32_t onExtLetterGridEntry()
8045 {
8046 NameEntryMode=2;
8047 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8048 return D_O_K;
8049 }
8050
8051 static BITMAP* oldscreen;
8052 int32_t onFullscreenMenu()
8053 {
8054 // super hacks
8055 screen = oldscreen;
8056 if (onFullscreen() == D_REDRAW)
8057 {
8058 oldscreen = screen;
8059 }
8060 screen = menu_bmp;
8061 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8062 return D_O_K;
8063 }
8064
8065 26 void fix_menu()
8066 {
8067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(!debug_enabled)
8068 26 settings_menu[18].text = NULL;
8069 26 }
8070
8071 static DIALOG system_dlg[] =
8072 {
8073 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8074 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8075 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8076 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8077 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8078 #ifndef ALLEGRO_MACOSX
8079 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8080 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8081 #else
8082 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8083 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8084 #endif
8085 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8086 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8087 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8088 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8089 };
8090
8091 static DIALOG system_dlg2[] =
8092 {
8093 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8094 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8095 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8096 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8097 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8098 #ifndef ALLEGRO_MACOSX
8099 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8100 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8101 #else
8102 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8103 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8104 #endif
8105 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8106 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8107 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8108 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8109 };
8110
8111 void reset_snapshot_format_menu()
8112 {
8113 for(int32_t i=0; i<ssfmtMAX; ++i)
8114 {
8115 snapshot_format_menu[i].flags=0;
8116 }
8117 }
8118
8119 int32_t onSetSnapshotFormat()
8120 {
8121 switch(active_menu->text[1])
8122 {
8123 case 'B': //"&BMP"
8124 SnapshotFormat=0;
8125 break;
8126
8127 case 'G': //"&GIF"
8128 SnapshotFormat=1;
8129 break;
8130
8131 case 'J': //"&JPG"
8132 SnapshotFormat=2;
8133 break;
8134
8135 case 'P': //"&PNG"
8136 SnapshotFormat=3;
8137 break;
8138
8139 case 'C': //"PC&X"
8140 SnapshotFormat=4;
8141 break;
8142
8143 case 'T': //"&TGA"
8144 SnapshotFormat=5;
8145 break;
8146
8147 case 'L': //"&LBM"
8148 SnapshotFormat=6;
8149 break;
8150 }
8151 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8152
8153 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8154 return D_O_K;
8155 }
8156
8157
8158 40 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8159 {
8160 PALETTE tmp;
8161
8162
2/2
✓ Branch 0 taken 10240 times.
✓ Branch 1 taken 40 times.
10280 for(int32_t i=0; i<256; i++)
8163 {
8164 10240 tmp[i].r=r;
8165 10240 tmp[i].g=g;
8166 10240 tmp[i].b=b;
8167 10240 }
8168
8169 40 fade_interpolate(src,tmp,dest,pos,from,to);
8170 40 }
8171
8172 40 void system_pal()
8173 {
8174 40 is_sys_pal = true;
8175 static PALETTE pal;
8176 40 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8177
8178 // set up the grayscale palette
8179
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 40 times.
2600 for(int32_t i=128; i<192; i++)
8180 {
8181 2560 pal[i].r = i-128;
8182 2560 pal[i].g = i-128;
8183 2560 pal[i].b = i-128;
8184 2560 }
8185 40 load_colorset(gui_colorset, pal);
8186
8187 40 color_layer(pal, pal, 24,16,16, 28, 128,191);
8188
8189
2/2
✓ Branch 0 taken 5120 times.
✓ Branch 1 taken 40 times.
5160 for(int32_t i=0; i<256; i+=2)
8190 {
8191 5120 int32_t v = (i>>3)+2;
8192 5120 int32_t c = (i>>3)+192;
8193 5120 pal[c] = _RGB(v,v,v+(v>>1));
8194 /*
8195 if(i<240)
8196 {
8197 _allegro_hline(tmp_scr,0,i,319,c);
8198 _allegro_hline(tmp_scr,0,i+1,319,c);
8199 }
8200 */
8201 5120 }
8202
8203 // draw the vertical screen gradient
8204
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 40 times.
9640 for(int32_t i=0; i<240; ++i)
8205 {
8206 9600 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8207 9600 }
8208
8209 /*
8210 palrstart= 10*63/255; palrend=166*63/255;
8211 palgstart= 36*63/255; palgend=202*63/255;
8212 palbstart=106*63/255; palbend=240*63/255;
8213 paldivs=32;
8214 for(int32_t i=0; i<paldivs; i++)
8215 {
8216 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8217 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8218 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8219 }
8220 */
8221 40 BITMAP *panorama = create_bitmap_ex(8,256,224);
8222 int32_t ts_height, ts_start;
8223
8224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8225 {
8226 clear_to_color(panorama,0);
8227 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8228 ts_height=224-passive_subscreen_height;
8229 ts_start=28;
8230 }
8231 else
8232 {
8233 40 blit(framebuf,panorama,0,0,0,0,256,224);
8234 40 ts_height=224;
8235 40 ts_start=0;
8236 }
8237
8238 // gray scale the current frame
8239
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 40 times.
9000 for(int32_t y=0; y<ts_height; y++)
8240 {
8241
2/2
✓ Branch 0 taken 2293760 times.
✓ Branch 1 taken 8960 times.
2302720 for(int32_t x=0; x<256; x++)
8242 {
8243 2293760 int32_t c = panorama->line[y+ts_start][x];
8244
2/2
✓ Branch 0 taken 2287870 times.
✓ Branch 1 taken 5890 times.
2293760 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8245 2293760 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8246 2293760 }
8247 8960 }
8248
8249 40 destroy_bitmap(panorama);
8250
8251 // display everything
8252 40 vsync();
8253 40 hw_palette = &pal;
8254 40 update_hw_pal = true;
8255
8256 // sys_pal = pal;
8257 40 memcpy(sys_pal,pal,sizeof(pal));
8258 40 }
8259
8260 void system_pal2()
8261 {
8262 is_sys_pal = true;
8263 static PALETTE RAMpal2;
8264 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8265
8266 /* Windows 2000 colors
8267 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8268 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8269 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8270 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8271 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8272 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8273 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8274 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8275
8276 byte palrstart= 10*63/255, palrend=166*63/255,
8277 palgstart= 36*63/255, palgend=202*63/255,
8278 palbstart=106*63/255, palbend=240*63/255,
8279 paldivs=7;
8280 for(int32_t i=0; i<paldivs; i++)
8281 {
8282 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8283 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8284 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8285 }
8286 */
8287
8288 /* Windows 98 colors
8289 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8290 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8291 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8292 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8293 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8294 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8295 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8296 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8297
8298 byte palrstart= 0*63/255, palrend=166*63/255,
8299 palgstart= 0*63/255, palgend=202*63/255,
8300 palbstart=128*63/255, palbend=240*63/255,
8301 paldivs=7;
8302 for(int32_t i=0; i<paldivs; i++)
8303 {
8304 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8305 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8306 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8307 }
8308 */
8309
8310 /* Windows 99 colors
8311 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8312 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8313 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8314 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8315 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8316 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8317 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8318 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8319 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8320
8321 byte palrstart= 0*63/255, palrend=166*63/255,
8322 palgstart= 0*63/255, palgend=202*63/255,
8323
8324 palbstart=128*63/255, palbend=240*63/255,
8325 paldivs=6;
8326 for(int32_t i=0; i<paldivs; i++)
8327 {
8328 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8329 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8330 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8331 }
8332 */
8333
8334
8335
8336 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8337 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8338 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8339 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8340 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8341 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8342 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8343 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8344 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8345
8346 byte palrstart= 0*63/255, palrend=166*63/255,
8347 palgstart= 0*63/255, palgend=202*63/255,
8348 palbstart=128*63/255, palbend=240*63/255,
8349 paldivs=6;
8350
8351 for(int32_t i=0; i<paldivs; i++)
8352 {
8353 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8354 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8355 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8356 }
8357
8358 gui_bg_color=jwin_pal[jcBOX];
8359 gui_fg_color=jwin_pal[jcBOXFG];
8360
8361 jwin_set_colors(jwin_pal);
8362
8363
8364 // set up the new palette
8365 for(int32_t i=128; i<192; i++)
8366 {
8367 RAMpal2[i].r = i-128;
8368 RAMpal2[i].g = i-128;
8369 RAMpal2[i].b = i-128;
8370 }
8371
8372 /*
8373 for(int32_t i=0; i<64; i++)
8374 {
8375 RAMpal2[128+i] = _RGB(i,i,i)1));
8376 }
8377 */
8378
8379 /*
8380
8381 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8382 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8383 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8384 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8385 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8386 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8387 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8388
8389 gui_fg_color=vc(14);
8390 gui_bg_color=vc(1);
8391
8392 jwin_set_colors(jwin_pal);
8393 */
8394
8395 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8396
8397 // set up the colors for the vertical screen gradient
8398 for(int32_t i=0; i<256; i+=2)
8399 {
8400 int32_t v = (i>>3)+2;
8401 int32_t c = (i>>3)+192;
8402 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8403
8404 /*
8405 if(i<240)
8406 {
8407 _allegro_hline(tmp_scr,0,i,319,c);
8408 _allegro_hline(tmp_scr,0,i+1,319,c);
8409 }
8410 */
8411 }
8412
8413 // hw_palette = &RAMpal;
8414 // update_hw_pal = true;
8415
8416 for(int32_t i=0; i<240; ++i)
8417 {
8418 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8419 }
8420
8421 /*
8422 byte palrstart= 10*63/255, palrend=166*63/255,
8423 palgstart= 36*63/255, palgend=202*63/255,
8424 palbstart=106*63/255, palbend=240*63/255,
8425 paldivs=32;
8426 for(int32_t i=0; i<paldivs; i++)
8427 {
8428 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8429 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8430 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8431 }
8432 */
8433 BITMAP *panorama = create_bitmap_ex(8,256,224);
8434 int32_t ts_height, ts_start;
8435
8436 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8437 {
8438 clear_to_color(panorama,0);
8439 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8440 ts_height=224-passive_subscreen_height;
8441 ts_start=28;
8442 }
8443 else
8444 {
8445 blit(framebuf,panorama,0,0,0,0,256,224);
8446 ts_height=224;
8447 ts_start=0;
8448 }
8449
8450 // gray scale the current frame
8451 for(int32_t y=0; y<ts_height; y++)
8452 {
8453 for(int32_t x=0; x<256; x++)
8454 {
8455 int32_t c = panorama->line[y+ts_start][x];
8456 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8457 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8458 }
8459 }
8460
8461 destroy_bitmap(panorama);
8462
8463 // display everything
8464 vsync();
8465 hw_palette = &RAMpal2;
8466 update_hw_pal = true;
8467
8468 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8469
8470 // sys_pal = pal;
8471 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8472 }
8473
8474 static uint32_t entered_sys_pal = 0;
8475 14 void enter_sys_pal()
8476 {
8477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8478 {
8479 if(entered_sys_pal)
8480 ++entered_sys_pal;
8481 return;
8482 }
8483 14 system_pal();
8484 14 ++entered_sys_pal;
8485 14 }
8486 14 void exit_sys_pal()
8487 {
8488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8489 {
8490
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8491 {
8492 14 game_pal();
8493 14 }
8494 14 }
8495 14 }
8496
8497 void switch_out_callback()
8498 {
8499 if (pause_in_background)
8500 {
8501 callback_switchin = 3;
8502 return;
8503 }
8504
8505 #ifdef _WIN32
8506 if(midi_patch_fix==0 || currmidi==-1)
8507 return;
8508
8509
8510 paused_midi_pos = midi_pos;
8511 zc_stop_midi();
8512 midi_paused=true;
8513 midi_suspended = midissuspHALTED;
8514 #endif
8515 }
8516
8517 void switch_in_callback()
8518 {
8519 if(pause_in_background)
8520 {
8521 return;
8522 }
8523
8524 #ifdef _WIN32
8525 if(midi_patch_fix==0 || currmidi==-1)
8526 return;
8527
8528 else
8529 {
8530 callback_switchin = 1;
8531 midi_suspended = midissuspRESUME;
8532 }
8533 #endif
8534 }
8535
8536 214 void game_pal()
8537 {
8538 214 is_sys_pal = false;
8539 214 entered_sys_pal = 0;
8540 214 clear_to_color(screen,BLACK);
8541 214 hw_palette = &RAMpal;
8542 214 update_hw_pal = true;
8543 214 }
8544
8545 static char bar_str[] = "";
8546
8547 14 void music_pause()
8548 {
8549 //al_pause_duh(tmplayer);
8550 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8551 14 zc_midi_pause();
8552 14 midi_paused=true;
8553 14 }
8554
8555 void music_resume()
8556 {
8557 //al_resume_duh(tmplayer);
8558 zcmusic_pause(zcmusic, ZCM_RESUME);
8559 zc_midi_resume();
8560 midi_paused=false;
8561 }
8562
8563 4019 void music_stop()
8564 {
8565 //al_stop_duh(tmplayer);
8566 //unload_duh(tmusic);
8567 //tmusic=NULL;
8568 //tmplayer=NULL;
8569 4019 zcmusic_stop(zcmusic);
8570 4019 zcmusic_unload_file(zcmusic);
8571 4019 zc_stop_midi();
8572 4019 midi_paused=false;
8573 4019 currmidi=-1;
8574 4019 }
8575
8576 void System()
8577 {
8578 mouse_down=gui_mouse_b();
8579 music_pause();
8580 pause_all_sfx();
8581 MenuOpen = true;
8582 system_pal();
8583 // FONT *oldfont=font;
8584 // font=tfont;
8585
8586 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8587 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8588
8589 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8590 #if DEVLEVEL > 1
8591 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8592 #endif
8593 game_menu[3].flags =
8594 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8595 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8596 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8597 clear_keybuf();
8598 show_mouse(screen);
8599
8600 DIALOG_PLAYER *p;
8601
8602 clear_bitmap(menu_bmp);
8603 oldscreen = screen;
8604 screen = menu_bmp;
8605
8606 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8607 {
8608 p = init_dialog(system_dlg2,-1);
8609 }
8610 else
8611 {
8612 p = init_dialog(system_dlg,-1);
8613 }
8614
8615 // drop the menu on startup if menu button pressed
8616 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8617 simulate_keypress(KEY_G << 8);
8618
8619 do
8620 {
8621 if(close_button_quit)
8622 {
8623 close_button_quit = false;
8624 f_Quit(qEXIT);
8625 if(Quit) break;
8626 }
8627 rest(17);
8628
8629 if(mouse_down && !gui_mouse_b())
8630 mouse_down=0;
8631
8632 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8633 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8634 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8635
8636 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8637 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8638 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8639 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8640 settings_menu[8].flags = NESquit?D_SELECTED:0;
8641 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8642 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8643 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8644 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8645 settings_menu[13].flags = volkeys?D_SELECTED:0;
8646 //Epilepsy Prevention
8647 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8648
8649 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8650 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8651 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8652
8653 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8654 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8655 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8656
8657 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8658 cheat_menu[0].flags = 0;
8659 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8660 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8661 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8662 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8663 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8664 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8665 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8666 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8667 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8668
8669 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8670 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8671 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8672 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8673 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8674 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8675 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8676 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8677 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8678 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8679 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8680 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8681 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8682 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8683 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8684
8685 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8686 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8687
8688 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8689 (char *)"Disable recording new saves" :
8690 (char *)"Enable recording new saves";
8691 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8692 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8693 (char *)"Stop recording" :
8694 (char *)"Stop replaying";
8695 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8696 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8697 (char *)"Disable snapshot all frames" :
8698 (char *)"Enable snapshot all frames";
8699
8700 reset_snapshot_format_menu();
8701 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8702
8703 if(debug_enabled)
8704 {
8705 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8706 }
8707
8708 if(gui_mouse_b() && !mouse_down)
8709 break;
8710
8711 // press menu to drop the menu
8712 if(rMbtn())
8713 simulate_keypress(KEY_G << 8);
8714
8715 if(input_idle(true) > after_time())
8716 // run Screeen Saver
8717 {
8718 // Screen saver enabled for now.
8719 clear_keybuf();
8720 scare_mouse();
8721 Matrix(ss_speed, ss_density, 0);
8722 system_pal();
8723 unscare_mouse();
8724 broadcast_dialog_message(MSG_DRAW, 0);
8725 }
8726
8727 update_hw_screen();
8728 }
8729 while(update_dialog(p));
8730
8731 screen = oldscreen;
8732
8733 // font=oldfont;
8734 mouse_down=gui_mouse_b();
8735 shutdown_dialog(p);
8736 show_mouse(NULL);
8737 MenuOpen = false;
8738 if(Quit)
8739 {
8740 kill_sfx();
8741 music_stop();
8742 update_hw_screen();
8743 }
8744 else
8745 {
8746 game_pal();
8747 music_resume();
8748 resume_all_sfx();
8749
8750 if(rc)
8751 ringcolor(false);
8752 }
8753
8754 eat_buttons();
8755
8756 rc=false;
8757 clear_keybuf();
8758 // text_mode(0);
8759 }
8760
8761 26 void fix_dialogs()
8762 {
8763 26 jwin_center_dialog(about_dlg);
8764 26 jwin_center_dialog(gamepad_dlg);
8765 26 jwin_center_dialog(credits_dlg);
8766 26 jwin_center_dialog(gamemode_dlg);
8767 26 jwin_center_dialog(getnum_dlg);
8768 26 jwin_center_dialog(goto_dlg);
8769 26 jwin_center_dialog(keyboard_control_dlg);
8770 26 jwin_center_dialog(midi_dlg);
8771 26 jwin_center_dialog(quest_dlg);
8772 26 jwin_center_dialog(scrsaver_dlg);
8773 26 jwin_center_dialog(sound_dlg);
8774 26 jwin_center_dialog(triforce_dlg);
8775
8776 // digi_dp[1] += scrx;
8777 // digi_dp[2] += scry;
8778 // midi_dp[1] += scrx;
8779 // midi_dp[2] += scry;
8780 // pan_dp[1] += scrx;
8781 // pan_dp[2] += scry;
8782 // emus_dp[1] += scrx;
8783 // emus_dp[2] += scry;
8784 // buf_dp[1] += scrx;
8785 // buf_dp[2] += scry;
8786 // sfx_dp[1] += scrx;
8787 // sfx_dp[2] += scry;
8788 26 }
8789
8790 /*****************************/
8791 /**** Custom Sound System ****/
8792 /*****************************/
8793
8794 1604 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8795 {
8796
3/4
✓ Branch 0 taken 1534 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 1604 times.
✗ Branch 3 not taken.
1604 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8797 }
8798
8799 // Run an NSF, or a MIDI if the NSF is missing somehow.
8800 64 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8801 {
8802 64 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8803
8804 // Found it
8805
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 25 times.
64 if(newzcmusic!=NULL)
8806 {
8807 39 zcmusic_stop(zcmusic);
8808 39 zcmusic_unload_file(zcmusic);
8809 39 zc_stop_midi();
8810
8811 39 zcmusic=newzcmusic;
8812 39 zcmusic_play(zcmusic, emusic_volume);
8813
8814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(track>0)
8815 39 zcmusic_change_track(zcmusic,track);
8816
8817 39 return true;
8818 }
8819
8820 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8821
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 else if(midi>-1000)
8822 jukebox(midi);
8823
8824 25 return false;
8825 64 }
8826
8827 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8828 {
8829 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8830 // Found it
8831 if(newzcmusic!=NULL)
8832 {
8833 zcmusic_stop(zcmusic);
8834 zcmusic_unload_file(zcmusic);
8835 zc_stop_midi();
8836
8837 zcmusic=newzcmusic;
8838 zcmusic_play(zcmusic, emusic_volume);
8839
8840 if(track>0)
8841 zcmusic_change_track(zcmusic,track);
8842
8843 return true;
8844 }
8845
8846 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8847 else if(midi>-1000)
8848 jukebox(midi);
8849
8850 return false;
8851 }
8852
8853 int32_t get_zcmusicpos()
8854 {
8855 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8856 return debugtracething;
8857 return 0;
8858 }
8859
8860 void set_zcmusicpos(int32_t position)
8861 {
8862 zcmusic_set_curpos(zcmusic, position);
8863 }
8864
8865 void set_zcmusicspeed(int32_t speed)
8866 {
8867 int32_t newspeed = vbound(speed, 0, 10000);
8868 zcmusic_set_speed(zcmusic, newspeed);
8869 }
8870
8871 789 void jukebox(int32_t index,int32_t loop)
8872 {
8873 789 music_stop();
8874
8875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 789 times.
789 if(index<0) index=MAXMIDIS-1;
8876
8877
1/2
✓ Branch 0 taken 789 times.
✗ Branch 1 not taken.
789 if(index>=MAXMIDIS) index=0;
8878
8879 789 music_stop();
8880
8881 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8882 // stuck notes when a song stops. This fixes it.
8883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 789 times.
789 if(strcmp(midi_driver->name, "DIGMID")==0)
8884 zc_set_volume(0, 0);
8885
8886 789 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8887 789 zc_play_midi((MIDI*)tunes[index].data,loop);
8888
8889
2/2
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 209 times.
789 if(tunes[index].start>0)
8890 209 zc_midi_seek(tunes[index].start);
8891
8892 789 midi_loop_start = tunes[index].loop_start;
8893 789 midi_loop_end = tunes[index].loop_end;
8894
8895 789 currmidi=index;
8896 789 master_volume(digi_volume,midi_volume);
8897 789 midi_paused=false;
8898 789 }
8899
8900 5378 void jukebox(int32_t index)
8901 {
8902
1/2
✓ Branch 0 taken 5378 times.
✗ Branch 1 not taken.
5378 if(index<0) index=MAXMIDIS-1;
8903
8904
1/2
✓ Branch 0 taken 5378 times.
✗ Branch 1 not taken.
5378 if(index>=MAXMIDIS) index=0;
8905
8906 // do nothing if it's already playing
8907
3/4
✓ Branch 0 taken 4589 times.
✓ Branch 1 taken 789 times.
✓ Branch 2 taken 4589 times.
✗ Branch 3 not taken.
5378 if(index==currmidi && midi_pos>=0)
8908 {
8909 4589 midi_paused=false;
8910 4589 return;
8911 }
8912
8913 789 jukebox(index,tunes[index].loop);
8914 5378 }
8915
8916 6466 void play_DmapMusic()
8917 {
8918 static char tfile[2048];
8919 static int32_t ttrack=0;
8920 6466 bool domidi=false;
8921
8922
2/2
✓ Branch 0 taken 1201 times.
✓ Branch 1 taken 5265 times.
6466 if(DMaps[currdmap].tmusic[0]!=0)
8923 {
8924
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 816 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1586 if(zcmusic==NULL ||
8925
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8926
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8927 {
8928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816 times.
816 if(zcmusic != NULL)
8929 {
8930 zcmusic_stop(zcmusic);
8931 zcmusic_unload_file(zcmusic);
8932 zcmusic = NULL;
8933 }
8934
8935 816 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8936
8937
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 730 times.
816 if(zcmusic!=NULL)
8938 {
8939 86 zc_stop_midi();
8940 86 strcpy(tfile,DMaps[currdmap].tmusic);
8941 86 zcmusic_play(zcmusic, emusic_volume);
8942 86 int32_t temptracks=0;
8943 86 temptracks=zcmusic_get_tracks(zcmusic);
8944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8945 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8946 86 zcmusic_change_track(zcmusic,ttrack);
8947 86 }
8948 else
8949 {
8950 730 tfile[0] = 0;
8951 730 domidi=true;
8952 }
8953 816 }
8954 1201 }
8955 else
8956 {
8957 5265 domidi=true;
8958 }
8959
8960
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 5995 times.
6466 if(domidi)
8961 {
8962 5995 int32_t m=DMaps[currdmap].midi;
8963
8964
3/4
✓ Branch 0 taken 5894 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
5995 switch(m)
8965 {
8966 case 1:
8967 91 jukebox(ZC_MIDI_OVERWORLD);
8968 91 break;
8969
8970 case 2:
8971 10 jukebox(ZC_MIDI_DUNGEON);
8972 10 break;
8973
8974 case 3:
8975 jukebox(ZC_MIDI_LEVEL9);
8976 break;
8977
8978 default:
8979
3/4
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 758 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5136 times.
5894 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8980 5136 jukebox(m+MIDIOFFSET_DMAP);
8981 else
8982 758 music_stop();
8983 5894 }
8984 5995 }
8985 6466 }
8986
8987 6503 void playLevelMusic()
8988 {
8989 6503 int32_t m=tmpscr->screen_midi;
8990
8991
3/6
✓ Branch 0 taken 6450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
6503 switch(m)
8992 {
8993 case -2:
8994 12 music_stop();
8995 12 break;
8996
8997 case -1:
8998 6450 play_DmapMusic();
8999 6450 break;
9000
9001 case 1:
9002 jukebox(ZC_MIDI_OVERWORLD);
9003 break;
9004
9005 case 2:
9006 jukebox(ZC_MIDI_DUNGEON);
9007 break;
9008
9009 case 3:
9010 jukebox(ZC_MIDI_LEVEL9);
9011 break;
9012
9013 default:
9014
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9015 41 jukebox(m+MIDIOFFSET_MAPSCR);
9016 else
9017 music_stop();
9018 41 }
9019 6503 }
9020
9021 815 void master_volume(int32_t dv,int32_t mv)
9022 {
9023
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 815 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 815 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 815 times.
✗ Branch 7 not taken.
815 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9024
9025
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 815 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 815 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 815 times.
✗ Branch 7 not taken.
815 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9026
9027
6/6
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 787 times.
✓ Branch 5 taken 27 times.
815 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9028 815 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9029 815 }
9030
9031 /*****************/
9032 /***** SFX *****/
9033 /*****************/
9034
9035 // array of voices, one for each sfx sample in the data file
9036 // 0+ = voice #
9037 // -1 = voice not allocated
9038 26 void Z_init_sound()
9039 {
9040
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 26 times.
6682 for(int32_t i=0; i<WAV_COUNT; i++)
9041 6656 sfx_voice[i]=-1;
9042
9043
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 26 times.
208 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9044 182 tunes[i].data = (MIDI*)mididata[i].dat;
9045
9046
2/2
✓ Branch 0 taken 6552 times.
✓ Branch 1 taken 26 times.
6578 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9047 6552 tunes[ZC_MIDI_COUNT+j].data=NULL;
9048
9049 26 master_volume(digi_volume,midi_volume);
9050 26 }
9051
9052 // returns number of voices currently allocated
9053 int32_t sfx_count()
9054 {
9055 int32_t c=0;
9056
9057 for(int32_t i=0; i<WAV_COUNT; i++)
9058 if(sfx_voice[i]!=-1)
9059 ++c;
9060
9061 return c;
9062 }
9063
9064 // clean up finished samples
9065 4627092 void sfx_cleanup()
9066 {
9067
2/2
✓ Branch 0 taken 1184535552 times.
✓ Branch 1 taken 4627092 times.
1189162644 for(int32_t i=0; i<WAV_COUNT; i++)
9068
3/4
✓ Branch 0 taken 444760 times.
✓ Branch 1 taken 1184090792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 444760 times.
1184980312 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9069 {
9070 444760 deallocate_voice(sfx_voice[i]);
9071 444760 sfx_voice[i]=-1;
9072 444760 }
9073 4627092 }
9074
9075 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9076 // if a voice is already allocated (and/or playing), then it just returns true
9077 // Returns true: voice is allocated
9078 // false: unsuccessful
9079 667456 bool sfx_init(int32_t index)
9080 {
9081 // check index
9082
3/4
✓ Branch 0 taken 487147 times.
✓ Branch 1 taken 180309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 487147 times.
667456 if(index<=0 || index>=WAV_COUNT)
9083 180309 return false;
9084
9085
2/2
✓ Branch 0 taken 42367 times.
✓ Branch 1 taken 444780 times.
487147 if(sfx_voice[index]==-1)
9086 {
9087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 444780 times.
444780 if(sfxdat)
9088 {
9089 if(index<Z35)
9090 {
9091 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9092 }
9093 else
9094 {
9095 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9096 }
9097 }
9098 else
9099 {
9100 444780 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9101 }
9102
9103 444780 voice_set_volume(sfx_voice[index], sfx_volume);
9104 444780 }
9105
9106 487147 return sfx_voice[index] != -1;
9107 667456 }
9108
9109 // plays an sfx sample
9110 572394 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9111 {
9112
2/2
✓ Branch 0 taken 425436 times.
✓ Branch 1 taken 146958 times.
572394 if(!sfx_init(index))
9113 146958 return;
9114
9115 425436 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9116 425436 voice_set_pan(sfx_voice[index],pan);
9117
9118 425436 int32_t pos = voice_get_position(sfx_voice[index]);
9119
9120
2/2
✓ Branch 0 taken 246021 times.
✓ Branch 1 taken 179415 times.
425436 if(restart) voice_set_position(sfx_voice[index],0);
9121
9122
1/2
✓ Branch 0 taken 425436 times.
✗ Branch 1 not taken.
425436 if(pos<=0)
9123 425436 voice_start(sfx_voice[index]);
9124 572394 }
9125
9126 // true if sfx is allocated
9127 21668 bool sfx_allocated(int32_t index)
9128 {
9129
2/4
✓ Branch 0 taken 21668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21668 times.
21668 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9130 }
9131
9132 // start it (in loop mode) if it's not already playing,
9133 // otherwise adjust it to play in loop mode -DD
9134 95062 void cont_sfx(int32_t index)
9135 {
9136
2/2
✓ Branch 0 taken 33351 times.
✓ Branch 1 taken 61711 times.
95062 if(!sfx_init(index))
9137 {
9138 33351 return;
9139 }
9140
9141
1/2
✓ Branch 0 taken 61711 times.
✗ Branch 1 not taken.
61711 if(voice_get_position(sfx_voice[index])<=0)
9142 {
9143 61711 voice_set_position(sfx_voice[index],0);
9144 61711 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9145 61711 voice_start(sfx_voice[index]);
9146 61711 }
9147 else
9148 {
9149 adjust_sfx(index, 128, true);
9150 }
9151 95062 }
9152
9153 // adjust parameters while playing
9154 2684 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9155 {
9156
5/6
✓ Branch 0 taken 1518 times.
✓ Branch 1 taken 1166 times.
✓ Branch 2 taken 1518 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1506 times.
2684 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9157 2672 return;
9158
9159 12 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9160 12 voice_set_pan(sfx_voice[index],pan);
9161 2684 }
9162
9163 // pauses a voice
9164 965 void pause_sfx(int32_t index)
9165 {
9166
3/6
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 965 times.
965 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9167 voice_stop(sfx_voice[index]);
9168 965 }
9169
9170 // resumes a voice
9171 460 void resume_sfx(int32_t index)
9172 {
9173
3/6
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 460 times.
460 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9174 voice_start(sfx_voice[index]);
9175 460 }
9176
9177 // pauses all active voices
9178 113 void pause_all_sfx()
9179 {
9180
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<WAV_COUNT; i++)
9181
2/2
✓ Branch 0 taken 28926 times.
✓ Branch 1 taken 2 times.
28930 if(sfx_voice[i]!=-1)
9182 2 voice_stop(sfx_voice[i]);
9183 113 }
9184
9185 // resumes all paused voices
9186 99 void resume_all_sfx()
9187 {
9188
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<WAV_COUNT; i++)
9189
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(sfx_voice[i]!=-1)
9190 voice_start(sfx_voice[i]);
9191 99 }
9192
9193 // stops an sfx and deallocates the voice
9194 3651426 void stop_sfx(int32_t index)
9195 {
9196
3/4
✓ Branch 0 taken 3559791 times.
✓ Branch 1 taken 91635 times.
✓ Branch 2 taken 3559791 times.
✗ Branch 3 not taken.
3651426 if(index<=0 || index>=WAV_COUNT)
9197 91635 return;
9198
9199
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3559778 times.
3559791 if(sfx_voice[index]!=-1)
9200 {
9201 13 deallocate_voice(sfx_voice[index]);
9202 13 sfx_voice[index]=-1;
9203 13 }
9204 3651426 }
9205
9206 // Stops SFX played by Hero's item of the given family
9207 131093 void stop_item_sfx(int32_t family)
9208 {
9209 131093 int32_t id=current_item_id(family);
9210
9211
2/2
✓ Branch 0 taken 130827 times.
✓ Branch 1 taken 266 times.
131093 if(id<0)
9212 130827 return;
9213
9214 266 stop_sfx(itemsbuf[id].usesound);
9215 131093 }
9216
9217 1254 void kill_sfx()
9218 {
9219
2/2
✓ Branch 0 taken 321024 times.
✓ Branch 1 taken 1254 times.
322278 for(int32_t i=0; i<WAV_COUNT; i++)
9220
2/2
✓ Branch 0 taken 321017 times.
✓ Branch 1 taken 7 times.
321031 if(sfx_voice[i]!=-1)
9221 {
9222 7 deallocate_voice(sfx_voice[i]);
9223 7 sfx_voice[i]=-1;
9224 7 }
9225 1254 }
9226
9227 371786 int32_t pan(int32_t x)
9228 {
9229
1/4
✓ Branch 0 taken 371786 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
371786 switch(pan_style)
9230 {
9231 case 0:
9232 return 128;
9233
9234 case 1:
9235 371786 return vbound((x>>1)+68,0,255);
9236
9237 case 2:
9238 return vbound(((x*3)>>2)+36,0,255);
9239 }
9240
9241 return vbound(x,0,255);
9242 371786 }
9243
9244 /*******************************/
9245 /******* Input Handlers ********/
9246 /*******************************/
9247
9248 10851847 bool joybtn(int32_t b)
9249 {
9250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10851847 times.
10851847 if(b == 0)
9251 return false;
9252
9253 10851847 return joy[joystick_index].button[b-1].b !=0;
9254 10851847 }
9255
9256 const char* joybtn_name(int32_t b)
9257 {
9258 if(b == 0)
9259 return "";
9260
9261 return joy[joystick_index].button[b-1].name;
9262 }
9263
9264 int32_t next_press_key()
9265 {
9266 return readkey()>>8;
9267 }
9268
9269 int32_t next_press_btn()
9270 {
9271 clear_keybuf();
9272 /*bool b[joy[joystick_index].num_buttons+1];
9273
9274 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9275 b[i]=joybtn(i);*/
9276
9277 //first, we need to wait until they're pressing no buttons
9278 for(;;)
9279 {
9280 if(keypressed())
9281 {
9282 switch(readkey()>>8)
9283 {
9284 case KEY_ESC:
9285 return -1;
9286
9287 case KEY_SPACE:
9288 return 0;
9289 }
9290 }
9291
9292 poll_joystick();
9293 bool done = true;
9294
9295 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9296 {
9297 if(joybtn(i)) done = false;
9298 }
9299
9300 if(done) break;
9301 rest(1);
9302 }
9303
9304 //now, we need to wait for them to press any button
9305 for(;;)
9306 {
9307 if(keypressed())
9308 {
9309 switch(readkey()>>8)
9310 {
9311 case KEY_ESC:
9312 return -1;
9313
9314 case KEY_SPACE:
9315 return 0;
9316 }
9317 }
9318
9319 poll_joystick();
9320
9321 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9322 {
9323 if(joybtn(i)) return i;
9324 }
9325 rest(1);
9326 }
9327 }
9328
9329 94330436 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9330 {
9331
2/2
✓ Branch 0 taken 90897560 times.
✓ Branch 1 taken 3432876 times.
94330436 bool ret = btn && !flag;
9332
2/2
✓ Branch 0 taken 88535165 times.
✓ Branch 1 taken 5795271 times.
94330436 flag = rawbtn ? *rawbtn : btn;
9333
9334 94330436 return ret;
9335 }
9336 864 static bool rButtonPeek(bool btn, bool flag)
9337 {
9338
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 36 times.
864 if(!btn)
9339 {
9340 828 return false;
9341 }
9342
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9343 {
9344 9 return true;
9345 }
9346
9347 27 return false;
9348 864 }
9349
9350 // Updated only by keyboard/gamepad.
9351 // If in replay mode, this is set directly by the replay system.
9352 // This should never be read from directly - use control_state instead.
9353 bool raw_control_state[ZC_CONTROL_STATES];
9354
9355 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9356 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9357 // lasts until the next call to load_control_state.
9358 bool control_state[ZC_CONTROL_STATES];
9359 bool disable_control[ZC_CONTROL_STATES];
9360 bool drunk_toggle_state[11];
9361 bool disabledKeys[127];
9362 bool KeyInput[127];
9363 bool KeyPress[127];
9364
9365 bool key_current_frame[127];
9366 bool key_previous_frame[127];
9367
9368 static bool key_system[127];
9369 static bool key_system_previous[127];
9370 static bool key_system_press[127];
9371
9372 bool button_press[ZC_CONTROL_STATES];
9373 bool button_hold[ZC_CONTROL_STATES];
9374
9375 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9376 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9377 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9378 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9379 #define STICK_PRECISION 56 //define your own sensitivity
9380
9381 3824435 void load_control_state()
9382 {
9383 3824435 load_control_called_this_frame = true;
9384
9385
4/4
✓ Branch 0 taken 3824432 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 953231 times.
✓ Branch 3 taken 2871201 times.
3824435 if (!replay_is_active() || replay_get_version() >= 8)
9386 {
9387
2/2
✓ Branch 0 taken 17158212 times.
✓ Branch 1 taken 953234 times.
18111446 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9388 17158212 down_control_states[i] = raw_control_state[i];
9389 953234 }
9390
9391
1/2
✓ Branch 0 taken 3824435 times.
✗ Branch 1 not taken.
3824435 if (!replay_is_replaying())
9392 {
9393 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9394 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9395 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9396 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9397 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9398 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9399 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9400 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9401 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9402 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9403 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9404 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9405 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9406 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9407
9408 if(num_joysticks != 0)
9409 {
9410 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9411 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9412 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9413 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9414 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9415 }
9416 else
9417 {
9418 raw_control_state[14] = false;
9419 raw_control_state[15] = false;
9420 raw_control_state[16] = false;
9421 raw_control_state[17] = false;
9422 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9423 }
9424 }
9425
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3824432 times.
3824435 if (replay_is_active())
9426 {
9427
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 2809217 times.
3824432 if (replay_get_version() < 3)
9428 1015215 replay_poll();
9429
3/4
✓ Branch 0 taken 2809217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047842 times.
✓ Branch 3 taken 1761375 times.
2809217 else if (replay_is_replaying() && replay_get_version() < 6)
9430 1761375 replay_peek_input();
9431
3/4
✓ Branch 0 taken 1047842 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94608 times.
✓ Branch 3 taken 953234 times.
1047842 else if (replay_is_replaying() && replay_get_version() >= 8)
9432 953234 replay_peek_input();
9433 3824432 }
9434
9435
2/2
✓ Branch 0 taken 2871298 times.
✓ Branch 1 taken 953131 times.
3824435 if (replay_get_version() == 8)
9436 {
9437 953131 update_keys();
9438 953131 }
9439
9440 // Some test replay files were made before a serious input bug was fixed, so instead
9441 // of re-doing them or tossing them out, just check for that zplay version.
9442
3/4
✓ Branch 0 taken 3824429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 3702529 times.
3824429 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9443
2/2
✓ Branch 0 taken 3824429 times.
✓ Branch 1 taken 68839722 times.
72664151 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9444 {
9445 68839722 control_state[i] = raw_control_state[i];
9446
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 19352412 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
68839722 if (botched_input && !control_state[i])
9447 47077142 down_control_states[i] = false;
9448 68839722 }
9449
9450 3824429 button_press[0]=rButton(control_state[0],button_hold[0]);
9451 3824429 button_press[1]=rButton(control_state[1],button_hold[1]);
9452 3824429 button_press[2]=rButton(control_state[2],button_hold[2]);
9453 3824429 button_press[3]=rButton(control_state[3],button_hold[3]);
9454 3824429 button_press[4]=rButton(control_state[4],button_hold[4]);
9455 3824429 button_press[5]=rButton(control_state[5],button_hold[5]);
9456 3824429 button_press[6]=rButton(control_state[6],button_hold[6]);
9457 3824429 button_press[7]=rButton(control_state[7],button_hold[7]);
9458 3824429 button_press[8]=rButton(control_state[8],button_hold[8]);
9459 3824429 button_press[9]=rButton(control_state[9],button_hold[9]);
9460 3824429 button_press[10]=rButton(control_state[10],button_hold[10]);
9461 3824429 button_press[11]=rButton(control_state[11],button_hold[11]);
9462 3824429 button_press[12]=rButton(control_state[12],button_hold[12]);
9463 3824429 button_press[13]=rButton(control_state[13],button_hold[13]);
9464 3824429 button_press[14]=rButton(control_state[14],button_hold[14]);
9465 3824429 button_press[15]=rButton(control_state[15],button_hold[15]);
9466 3824429 button_press[16]=rButton(control_state[16],button_hold[16]);
9467 3824429 button_press[17]=rButton(control_state[17],button_hold[17]);
9468 3824429 }
9469
9470 // Returns true if any game key is pressed. This is needed because keypressed()
9471 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9472 19721062 bool zc_key_pressed()
9473 //may also need to use zc_getrawkey
9474 {
9475
7/10
✓ Branch 0 taken 15915292 times.
✓ Branch 1 taken 3805770 times.
✓ Branch 2 taken 3805770 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3805770 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3219268 times.
✓ Branch 7 taken 3219268 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1057929 times.
20778991 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9476
4/6
✓ Branch 0 taken 3219268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3219268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2410622 times.
✓ Branch 5 taken 2410622 times.
3219268 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9477
4/6
✓ Branch 0 taken 2410622 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2410622 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1523998 times.
✓ Branch 5 taken 1523998 times.
2410622 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9478
4/6
✓ Branch 0 taken 1523998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1523998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1217639 times.
✓ Branch 5 taken 1217639 times.
1523998 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9479
1/2
✓ Branch 0 taken 1217639 times.
✗ Branch 1 not taken.
1217639 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9480
3/4
✓ Branch 0 taken 1139382 times.
✓ Branch 1 taken 78257 times.
✓ Branch 2 taken 1139382 times.
✗ Branch 3 not taken.
1217639 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9481
3/4
✓ Branch 0 taken 1077574 times.
✓ Branch 1 taken 61808 times.
✓ Branch 2 taken 1077574 times.
✗ Branch 3 not taken.
1139382 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9482
3/4
✓ Branch 0 taken 1066801 times.
✓ Branch 1 taken 10773 times.
✓ Branch 2 taken 1066801 times.
✗ Branch 3 not taken.
1077574 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9483
3/4
✓ Branch 0 taken 1059156 times.
✓ Branch 1 taken 7645 times.
✓ Branch 2 taken 1059156 times.
✗ Branch 3 not taken.
1066801 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9484
3/4
✓ Branch 0 taken 1058756 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 1058756 times.
✗ Branch 3 not taken.
1059156 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9485
3/4
✓ Branch 0 taken 1058714 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 1058714 times.
✗ Branch 3 not taken.
1058756 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9486
3/4
✓ Branch 0 taken 1057948 times.
✓ Branch 1 taken 766 times.
✓ Branch 2 taken 1057948 times.
✗ Branch 3 not taken.
1058714 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9487
2/4
✓ Branch 0 taken 1057948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1057948 times.
✗ Branch 3 not taken.
1057948 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9488
2/2
✓ Branch 0 taken 1057929 times.
✓ Branch 1 taken 19 times.
1057948 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9489 35406187 return true;
9490
9491 1057929 return false;
9492 4633532 }
9493
9494 75928767 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9495 {
9496 75928767 bool ret = false, drunkstate = false, rawret = false;
9497 75928767 bool* flag = &down_control_states[btn];
9498
2/7
✓ Branch 0 taken 71290420 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4638347 times.
75928767 switch(btn)
9499 {
9500 case btnF12:
9501 ret = zc_getkey(KEY_F12, ignoreDisable);
9502 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9503 eatEntirely = false;
9504 break;
9505 case btnF11:
9506 ret = zc_getkey(KEY_F11, ignoreDisable);
9507 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9508 eatEntirely = false;
9509 break;
9510 case btnF5:
9511 ret = zc_getkey(KEY_F5, ignoreDisable);
9512 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9513 eatEntirely = false;
9514 break;
9515 case btnQ:
9516 ret = zc_getkey(KEY_Q, ignoreDisable);
9517 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9518 eatEntirely = false;
9519 break;
9520 case btnI:
9521 ret = zc_getkey(KEY_I, ignoreDisable);
9522 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9523 eatEntirely = false;
9524 break;
9525 case btnM:
9526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4638347 times.
4638347 if(FFCore.kb_typing_mode) return false;
9527 4638347 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9528 4638347 eatEntirely = false;
9529 4638347 break;
9530 default: //control_state[] index
9531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71290420 times.
71290420 if(FFCore.kb_typing_mode) return false;
9532
5/6
✓ Branch 0 taken 71129548 times.
✓ Branch 1 taken 160872 times.
✓ Branch 2 taken 1907010 times.
✓ Branch 3 taken 69222538 times.
✓ Branch 4 taken 1907010 times.
✗ Branch 5 not taken.
71290420 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9533
2/2
✓ Branch 0 taken 3848992 times.
✓ Branch 1 taken 67441428 times.
71290420 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9534
4/4
✓ Branch 0 taken 63807014 times.
✓ Branch 1 taken 7483406 times.
✓ Branch 2 taken 1175 times.
✓ Branch 3 taken 7482231 times.
78773826 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9535 71290420 rawret = raw_control_state[btn];
9536 71290420 }
9537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75928767 times.
75928767 assert(flag);
9538
2/2
✓ Branch 0 taken 50437189 times.
✓ Branch 1 taken 25491578 times.
75928767 if(press)
9539 {
9540
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 25490714 times.
25491578 if(peek)
9541 864 ret = rButtonPeek(ret, *flag);
9542
3/4
✓ Branch 0 taken 25490714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5795271 times.
✓ Branch 3 taken 19695443 times.
25490714 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9543 5795271 else ret = rButton(ret, *flag, &rawret);
9544 25491578 }
9545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75928767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75928767 if(eatEntirely && ret) control_state[btn] = false;
9546
3/4
✓ Branch 0 taken 57275425 times.
✓ Branch 1 taken 18653342 times.
✓ Branch 2 taken 57275425 times.
✗ Branch 3 not taken.
75928767 if(drunk && drunkstate) ret = !ret;
9547 75928767 return ret;
9548 75928767 }
9549
9550 369200 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9551 {
9552 369200 byte ret = 0;
9553
2/2
✓ Branch 0 taken 366817 times.
✓ Branch 1 taken 2383 times.
369200 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9554
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9555
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9556
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9557
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9558
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9559
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9560
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9561 369200 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9562 }
9563
9564 561 byte checkIntBtnVal(byte intbtn, byte vals)
9565 {
9566 561 return intbtn&vals;
9567 }
9568
9569 879525 bool Up()
9570 {
9571 879525 return getInput(btnUp);
9572 }
9573 48003 bool Down()
9574 {
9575 48003 return getInput(btnDown);
9576 }
9577 110898 bool Left()
9578 {
9579 110898 return getInput(btnLeft);
9580 }
9581 122995 bool Right()
9582 {
9583 122995 return getInput(btnRight);
9584 }
9585 40108 bool cAbtn()
9586 {
9587 40108 return getInput(btnA);
9588 }
9589 669462 bool cBbtn()
9590 {
9591 669462 return getInput(btnB);
9592 }
9593 bool cSbtn()
9594 {
9595 return getInput(btnS);
9596 }
9597 6440 bool cLbtn()
9598 {
9599 6440 return getInput(btnL);
9600 }
9601 6440 bool cRbtn()
9602 {
9603 6440 return getInput(btnR);
9604 }
9605 bool cPbtn()
9606 {
9607 return getInput(btnP);
9608 }
9609 bool cEx1btn()
9610 {
9611 return getInput(btnEx1);
9612 }
9613 bool cEx2btn()
9614 {
9615 return getInput(btnEx2);
9616 }
9617 bool cEx3btn()
9618 {
9619 return getInput(btnEx3);
9620 }
9621 bool cEx4btn()
9622 {
9623 return getInput(btnEx4);
9624 }
9625 bool AxisUp()
9626 {
9627 return getInput(btnAxisUp);
9628 }
9629 bool AxisDown()
9630 {
9631 return getInput(btnAxisDown);
9632 }
9633 bool AxisLeft()
9634 {
9635 return getInput(btnAxisLeft);
9636 }
9637 bool AxisRight()
9638 {
9639 return getInput(btnAxisRight);
9640 }
9641
9642 bool cMbtn()
9643 {
9644 return getInput(btnM);
9645 }
9646 bool cF12()
9647 {
9648 return getInput(btnF12);
9649 }
9650 bool cF11()
9651 {
9652 return getInput(btnF11);
9653 }
9654 bool cF5()
9655 {
9656 return getInput(btnF5);
9657 }
9658 bool cQ()
9659 {
9660 return getInput(btnQ);
9661 }
9662 bool cI()
9663 {
9664 return getInput(btnI);
9665 }
9666
9667 66879 bool rUp()
9668 {
9669 66879 return getInput(btnUp, true);
9670 }
9671 66835 bool rDown()
9672 {
9673 66835 return getInput(btnDown, true);
9674 }
9675 66805 bool rLeft()
9676 {
9677 66805 return getInput(btnLeft, true);
9678 }
9679 66396 bool rRight()
9680 {
9681 66396 return getInput(btnRight, true);
9682 }
9683 455 bool rAbtn()
9684 {
9685 455 return getInput(btnA, true);
9686 }
9687 67316 bool rBbtn()
9688 {
9689 67316 return getInput(btnB, true);
9690 }
9691 3697343 bool rSbtn()
9692 {
9693 3697343 return getInput(btnS, true);
9694 }
9695 4633532 bool rMbtn()
9696 {
9697 4633532 return getInput(btnM, true);
9698 }
9699 66242 bool rLbtn()
9700 {
9701 66242 return getInput(btnL, true);
9702 }
9703 66239 bool rRbtn()
9704 {
9705 66239 return getInput(btnR, true);
9706 }
9707 3636024 bool rPbtn()
9708 {
9709 3636024 return getInput(btnP, true);
9710 }
9711 bool rEx1btn()
9712 {
9713 return getInput(btnEx1, true);
9714 }
9715 bool rEx2btn()
9716 {
9717 return getInput(btnEx2, true);
9718 }
9719 66799 bool rEx3btn()
9720 {
9721 66799 return getInput(btnEx3, true);
9722 }
9723 66799 bool rEx4btn()
9724 {
9725 66799 return getInput(btnEx4, true);
9726 }
9727 bool rAxisUp()
9728 {
9729 return getInput(btnAxisUp, true);
9730 }
9731 bool rAxisDown()
9732 {
9733 return getInput(btnAxisDown, true);
9734 }
9735 bool rAxisLeft()
9736 {
9737 return getInput(btnAxisLeft, true);
9738 }
9739 bool rAxisRight()
9740 {
9741 return getInput(btnAxisRight, true);
9742 }
9743
9744 bool rF11()
9745 {
9746 return getInput(btnF11, true);
9747 }
9748 bool rQ()
9749 {
9750 return getInput(btnQ, true);
9751 }
9752 bool rI()
9753 {
9754 return getInput(btnI, true);
9755 }
9756
9757 9535663 bool DrunkUp()
9758 {
9759 9535663 return getInput(btnUp, false, true);
9760 }
9761 8893007 bool DrunkDown()
9762 {
9763 8893007 return getInput(btnDown, false, true);
9764 }
9765 5695535 bool DrunkLeft()
9766 {
9767 5695535 return getInput(btnLeft, false, true);
9768 }
9769 4978792 bool DrunkRight()
9770 {
9771 4978792 return getInput(btnRight, false, true);
9772 }
9773 4128717 bool DrunkcAbtn()
9774 {
9775 4128717 return getInput(btnA, false, true);
9776 }
9777 4026930 bool DrunkcBbtn()
9778 {
9779 4026930 return getInput(btnB, false, true);
9780 }
9781 3629267 bool DrunkcEx1btn()
9782 {
9783 3629267 return getInput(btnEx1, false, true);
9784 }
9785 3629287 bool DrunkcEx2btn()
9786 {
9787 3629287 return getInput(btnEx2, false, true);
9788 }
9789 bool DrunkcSbtn()
9790 {
9791 return getInput(btnS, false, true);
9792 }
9793 bool DrunkcMbtn()
9794 {
9795 return getInput(btnM, false, true);
9796 }
9797 bool DrunkcLbtn()
9798 {
9799 return getInput(btnL, false, true);
9800 }
9801 bool DrunkcRbtn()
9802 {
9803 return getInput(btnR, false, true);
9804 }
9805 bool DrunkcPbtn()
9806 {
9807 return getInput(btnP, false, true);
9808 }
9809
9810 bool DrunkrUp()
9811 {
9812 return getInput(btnUp, true, true);
9813 }
9814 bool DrunkrDown()
9815 {
9816 return getInput(btnDown, true, true);
9817 }
9818 bool DrunkrLeft()
9819 {
9820 return getInput(btnLeft, true, true);
9821 }
9822 bool DrunkrRight()
9823 {
9824 return getInput(btnRight, true, true);
9825 }
9826 3001756 bool DrunkrAbtn()
9827 {
9828 3001756 return getInput(btnA, true, true);
9829 }
9830 2992648 bool DrunkrBbtn()
9831 {
9832 2992648 return getInput(btnB, true, true);
9833 }
9834 71669 bool DrunkrEx1btn()
9835 {
9836 71669 return getInput(btnEx1, true, true);
9837 }
9838 71662 bool DrunkrEx2btn()
9839 {
9840 71662 return getInput(btnEx2, true, true);
9841 }
9842 bool DrunkrEx3btn()
9843 {
9844 return getInput(btnEx3, true, true);
9845 }
9846 bool DrunkrEx4btn()
9847 {
9848 return getInput(btnEx4, true, true);
9849 }
9850 bool DrunkrSbtn()
9851 {
9852 return getInput(btnS, true, true);
9853 }
9854 bool DrunkrMbtn()
9855 {
9856 return getInput(btnM, true, true);
9857 }
9858 3309963 bool DrunkrLbtn()
9859 {
9860 3309963 return getInput(btnL, true, true);
9861 }
9862 3308146 bool DrunkrRbtn()
9863 {
9864 3308146 return getInput(btnR, true, true);
9865 }
9866 bool DrunkrPbtn()
9867 {
9868 return getInput(btnP, true, true);
9869 }
9870
9871 4815 void eat_buttons()
9872 {
9873 4815 getInput(btnA, true, false, true);
9874 4815 getInput(btnB, true, false, true);
9875 4815 getInput(btnS, true, false, true);
9876 4815 getInput(btnM, true, false, true);
9877 4815 getInput(btnL, true, false, true);
9878 4815 getInput(btnR, true, false, true);
9879 4815 getInput(btnP, true, false, true);
9880 4815 getInput(btnEx1, true, false, true);
9881 4815 getInput(btnEx2, true, false, true);
9882 4815 getInput(btnEx3, true, false, true);
9883 4815 getInput(btnEx4, true, false, true);
9884 4815 }
9885
9886 // Is true for the _first frame_ of a key press.
9887 // But! it is possible that a script manually sets the value of KeyPress,
9888 // in which case it will be restored to the "true" value based on `key_current_frame`
9889 // and `key_previous_frame` on the next frame.
9890 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9891 {
9892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9894 {
9895 case KEY_F7:
9896 case KEY_F8:
9897 case KEY_F9:
9898 return KeyPress[k];
9899
9900 default:
9901
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9902 }
9903 14 }
9904
9905 // Is true for _every frame_ a key is held down.
9906 // But! it is possible that a script manually sets the value of KeyInput,
9907 // in which case it will be restored to the "true" value based on `key_current_frame`
9908 // on the next frame.
9909 bool zc_getkey(int32_t k, bool ignoreDisable)
9910 {
9911 if(ignoreDisable) return KeyInput[k];
9912 switch(k)
9913 {
9914 case KEY_F7:
9915 case KEY_F8:
9916 case KEY_F9:
9917 return KeyInput[k];
9918
9919 default:
9920 return KeyInput[k] && !disabledKeys[k];
9921 }
9922 }
9923
9924 // Reads (and then clears) the current frame key state directly.
9925 // Scripts can also modify `key_current_frame`.
9926 52260528 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9927 {
9928
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 52260527 times.
52260528 if(zc_getrawkey(k, ignoreDisable))
9929 {
9930 1 _key[k]=key[k]=key_current_frame[k]=0;
9931 1 return true;
9932 }
9933 52260527 _key[k]=key[k]=key_current_frame[k]=0;
9934 52260527 return false;
9935 52260528 }
9936
9937 // Reads the current frame key state directly.
9938 // Scripts can also modify `key_current_frame`.
9939 82285983 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9940 {
9941
2/2
✓ Branch 0 taken 25391983 times.
✓ Branch 1 taken 56894000 times.
82285983 if(ignoreDisable) return key_current_frame[k];
9942
2/2
✓ Branch 0 taken 26130220 times.
✓ Branch 1 taken 30763780 times.
56894000 switch(k)
9943 {
9944 case KEY_F7:
9945 case KEY_F8:
9946 case KEY_F9:
9947 26130220 return key_current_frame[k];
9948
9949 default:
9950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30763780 times.
30763780 return key_current_frame[k] && !disabledKeys[k];
9951 }
9952 82285983 }
9953
9954 // Only used for a handful of keys, like tilde and Function keys.
9955 // This state is never read within the game.
9956 // It exists so that all keyboard input still functions during replay,
9957 // without inadvertently doing things like toggling throttling if the player
9958 // presses ~
9959 9267120 bool zc_get_system_key(int32_t k)
9960 {
9961 9267120 return key_system[k];
9962 }
9963
9964 // True for the _first_ frame of a key press.
9965 41701788 bool zc_read_system_key(int32_t k)
9966 {
9967 41701788 return key_system_press[k];
9968 }
9969
9970 588458564 bool is_system_key(int32_t k)
9971 {
9972
2/2
✓ Branch 0 taken 546756776 times.
✓ Branch 1 taken 41701788 times.
588458564 switch (k)
9973 {
9974 case KEY_BACKQUOTE:
9975 case KEY_CLOSEBRACE:
9976 case KEY_END:
9977 case KEY_HOME:
9978 case KEY_OPENBRACE:
9979 case KEY_PGDN:
9980 case KEY_PGUP:
9981 case KEY_TAB:
9982 case KEY_TILDE:
9983 41701788 return true;
9984 }
9985 546756776 return is_Fkey(k);
9986 588458564 }
9987
9988 4633532 void update_system_keys()
9989 {
9990
2/2
✓ Branch 0 taken 588458564 times.
✓ Branch 1 taken 4633532 times.
593092096 for (int32_t q = 0; q < 127; ++q)
9991 {
9992
2/2
✓ Branch 0 taken 97304172 times.
✓ Branch 1 taken 491154392 times.
588458564 if (!is_system_key(q))
9993 491154392 continue;
9994
9995 97304172 key_system[q] = key[q];
9996
1/2
✓ Branch 0 taken 97304172 times.
✗ Branch 1 not taken.
97304172 key_system_press[q] = key_system[q] && !key_system_previous[q];
9997 97304172 key_system_previous[q] = key_system[q];
9998 97304172 }
9999 4633532 }
10000
10001 5586663 void update_keys()
10002 {
10003
2/2
✓ Branch 0 taken 709506201 times.
✓ Branch 1 taken 5586663 times.
715092864 for (int32_t q = 0; q < 127; ++q)
10004 {
10005 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10006
1/2
✓ Branch 0 taken 709506201 times.
✗ Branch 1 not taken.
709506201 if (!replay_is_replaying())
10007 key_current_frame[q] = key[q];
10008
10009
2/2
✓ Branch 0 taken 704575814 times.
✓ Branch 1 taken 4930387 times.
709506201 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10010 709506201 KeyInput[q] = key_current_frame[q];
10011 709506201 key_previous_frame[q] = key_current_frame[q];
10012 709506201 }
10013 5586663 }
10014
10015 bool zc_disablekey(int32_t k, bool val)
10016 {
10017 switch(k)
10018 {
10019 case KEY_F7:
10020 case KEY_F8:
10021 case KEY_F9:
10022 return false;
10023
10024 default:
10025 disabledKeys[k] = val;
10026 return true;
10027 }
10028 }
10029
10030 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10031 {
10032 timer=timer;
10033 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10034 }
10035
10036 // these are here so that copy_dialog won't choke when compiling zelda
10037 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10038 {
10039 return D_O_K;
10040 }
10041
10042 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10043 {
10044 return D_O_K;
10045 }
10046
10047 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10048 {
10049 return D_O_K;
10050 }
10051
10052 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10053 {
10054 return D_O_K;
10055 }
10056
10057 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10058 {
10059 return D_O_K;
10060 }
10061
10062 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10063 {
10064 return D_O_K;
10065 }
10066
10067 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10068 {
10069 return D_O_K;
10070 }
10071
10072 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10073 {
10074 return D_O_K;
10075 }
10076
10077 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10078 {
10079 return D_O_K;
10080 }
10081
10082 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10083 {
10084 return D_O_K;
10085 }
10086
10087 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10088 {
10089 return D_O_K;
10090 }
10091
10092 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10093 {
10094 return D_O_K;
10095 }
10096
10097 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10098 {
10099 return D_O_K;
10100 }
10101
10102 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10103 {
10104 return D_O_K;
10105 }
10106
10107 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10108 {
10109 return D_O_K;
10110 }
10111
10112 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10113 {
10114 return D_O_K;
10115 }
10116
10117 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10118 {
10119 return D_O_K;
10120 }
10121
10122 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10123 {
10124 return D_O_K;
10125 }
10126
10127 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10128 {
10129 return D_O_K;
10130 }
10131
10132 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10133 {
10134 return D_O_K;
10135 }
10136
10137 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10138 {
10139 return D_O_K;
10140 }
10141
10142 /*** end of zc_sys.cc ***/
10143
10144